i’m simply trying to follow online tutorials provided by Google and other websites to create a listview populated with a static array of data. My activity class contains the following code:
public class HelloListActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, PENS));
}
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
String pen = o.toString();
Toast.makeText(this, "You have chosen the pen: " + " " + pen, Toast.LENGTH_LONG).show();
}
static final String[] PENS = new String[] { "MONT Blanc", "Gucci", "Parker", "Sailor", "Porsche Design", "Rotring", "Sheaffer", "Waterman" };
}
When I try to run this in the emulator, I get the following exception in logcat:
10-23 12:34:44.019: ERROR/AndroidRuntime(679): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.testproj/com.testproj.ListActivity}: java.lang.ClassNotFoundException: com.testproj.ListActivity in loader dalvik.system.PathClassLoader[/data/app/com.testproj-2.apk]
Any thoughts on where I should look for this problem? I’ve simply created a new android project in Eclipse and replaced the activity code with the above, hoping to produce a listview of the static data.
Thanks for any thoughts
Check the manifest.xml. I reckon you renamed the class but didn’t update the maifest.
com.testproj.ListActivity is the name of the class Android is trying to run but yours is HelloListActivity.