I\'m using android listview and its working perfectly fine. my implementation as below
ListView listview = (ListView)findViewById(R.id.list);
setListAdapter(new
Well from you code where you are using
setListAdapter(adapter);
indicates that you are using ListActivity
, and while using ListActivity
you get your list as follow:
listView = this.getListView();
or you can use
listView = this.findViewById(android.R.id.list);
and you are using
listView = this.findViewById(R.id.list);
which is wrong in case of ListActivity
, and ListView
cannot be found and results in NullPointerException
.
Try like this.
Public class ABCD implements OnItemClickListener{
ListView listview;//class varible
listview = (ListView)findViewById(R.id.list);
setListAdapter(new ArrayAdapter<String>(MyIncidentActivity.this,
R.layout.row_incident, R.id.label_incident, db_results));
listview.setOnItemClickListener(this);
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
}
}