public class List_Items extends ListActivity{
private ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_item);
List <ImageAndText> total_list=new ArrayList<ImageAndText>();
ListView lv = (ListView) this.findViewById(android.R.id.list);
lv.setAdapter((ListAdapter) new ImageAndTextListAdapter(this, total_list));
getListView().setTextFilterEnabled(true);
//////////////////////////////////////////////////////
Button btn=(Button) findViewById(R.id.button_sync);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast message=Toast.makeText(getApplicationContext(), "click the list_item", Toast.LENGTH_LONG);
message.show();}
});
}
public void onListItemClick(ListView parent, View v, int position, long id)
{
Toast.makeText(getApplicationContext(), "You have selected " +(position+1)+"th item",
Toast.LENGTH_SHORT).show();}
}
I have this list_item which is extends the listactivity. However, when I click on one of the row, the callback onListItemClick didn’t get activated. Why is that? I don’t need to anything with the adapter on this right?
}
You have to use the following in all the widgets of xml which you are inflating for your custom ListView.
Hope it helps