I just wanted to use ListView without extending ListActivity (because I’m extending my abstract class with actionbar). So, how to use simple ArrayList with it? I tried:
ListView lv = (ListView) findViewById(R.layout.list);
lv.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, myArrayList));
But my app crashed with error on the last line (lv.setAdapter......). What should I do, please?
EDIT:
Your
lvvariable isnullbecause you are trying to get yourListViewviaR.layout.list. You should get it viaR.id.your_list_id.Also, you shouldn’t use ListViews with regular Activities like this. You should use a ListActivity instead. You can check how to use it here: http://developer.android.com/reference/android/app/ListActivity.html