How can I set onClickListener on ArrayAdapter?
Solution 1:
you can also do like this..
moreListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Log.d("############","Items " + MoreItems[arg2] );
}
});
Solution 2:
There are two option to handle click event for each row.
1) If your class extends ListActivity
, you can override following method.
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
//do something here using the position in the array
}
2) Handle click event of row in getView()
method
row.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});