-2

My android app gives me this error from logcat:

Caused by: java.lang.RunTimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

this is my code:

package com.WNF;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.app.ListActivity;
import android.content.Intent;


public class Actiemenu extends ListActivity{

@Override 
public void onCreate(Bundle savedInstanceState) { 

super.onCreate(savedInstanceState); 
setContentView (R.layout.actiemenu);

final String[] array = new String[] {
        "Ding", "AnderDing", "Nogeending", "laatseding"
    };

setListAdapter(new ArrayAdapter<String> (this, R.layout.actiemenu, array));
    ListView lv = getListView();
    lv.setTextFilterEnabled(true);



lv.setOnItemClickListener(new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

        if (position == 0) {
            Intent een = new Intent(v.getContext(), Acties.class);
            startActivity(een);
        }
        else if (position == 1) {
            Intent twee = new Intent(v.getContext(), Acties2.class);
            startActivity(twee);
        }
    }
});
getIntent();
}
}

Any ideas what can be the problem??

GAMA
  • 5,958
  • 14
  • 79
  • 126

2 Answers2

2

Place the ListView in your main.xml with id of

<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
0

Import this

import your.package.name.R

in your case:

import com.WNF.R

This problem shows up when we import

android.R

instead of

package.name.R;
drulabs
  • 3,071
  • 28
  • 35