I've got an activity which is formed by four buttons. When I click one of them I go to another activity. All the buttons work well, but when I click the fourth the app stops. The activity must be started is formed by a ListView. Here is the code of that activity:
public class InformationActivity extends ListActivity {
String[] elements = {"About", "Rate"};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.information_layout);
ListView listview = (ListView)findViewById(R.id.optionslist);
listview.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, elements));
}
public void onListItemClick(ListView parent, View v, int position, long id) {
if ("About".equals(elements[position]))
{Intent i = new Intent(this, AboutActivity.class);
startActivity(i);}
else if ("Rate".equals(elements[position]))
{Intent i = new Intent(this, FeedbackActivity.class);
startActivity(i);}
}
}
Checking the LogCat, I find the following error:
08-22 12:34:57.649: E/AndroidRuntime(1361): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.isa.gestordecurso/com.isa.gestordecurso.InformationActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
I don't understand the error. The id of the ListView in the XML is optionslist, which is defined in the Activity.
Hope there's a solution: Thanks!