I have a customised row layout containing a Imageview and TextView for a List view. I can add a array of strings representing each row to the ArrayAdater but am having trouble populating the row ImageViews.
I have tried creating a ImageView array and added to ArrayAdaptor as follows (as I could not see a ArrayAdpter constructor that takes two Arrays as arguments):
// a string array holding the list items
String classes[] = { "My Profile", "Splash", "Log A Dive", "Search Dives",
"Weather: Magic Seaweed", "Irish Tides", "International Tides", "Dive PLanner" };// each class is a menu Actiitem
ImageView images[]={(ImageView) findViewById(R.drawable.logdive),(ImageView) findViewById(R.drawable.logdive2),
(ImageView) findViewById(R.drawable.logdive3),
(ImageView) findViewById(R.drawable.search),(ImageView) findViewById(R.drawable.weather),
(ImageView) findViewById(R.drawable.tides),(ImageView) findViewById(R.drawable.tides)
,(ImageView) findViewById(R.drawable.logdive3)};
ArrayAdapter listadaptor = new ArrayAdapter<String>(MainMenu.this,
R.layout.single_list_row, R.id.title, classes);
listadaptor.add(images);
setListAdapter(cutsomAdaptor);
Logcat Stack track:
01-02 05:10:45.480: E/AndroidRuntime(891): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mooney.diveapp/com.mooney.diveapp.MainMenu}: java.lang.NullPointerException