Making the cell of a listview clickable in listview in android
hi how to make the cell of a listview clickable in listview in android ? The list view is in Activit开发者_开发百科y and not in ListActivity
listView.setOnItemClickListener(new OnItemClickListener()
{
@SuppressWarnings("static-access")
public void onItemClick(AdapterView<?> arg0, View v, int position,long id)
{
// Your Code
// Use Position
}
}
Try this
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ListView list = getListView();
list.setBackgroundResource(R.drawable.background);
ListAdapter adapter = createAdapter();
setListAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View v, int position,
long id) {
System.out.println("" + position);
callGridView(position);
}// end of onItemClick
});// end of setOnItemClickListener
}// end of oncreate
精彩评论