I'm using 4list views with class extending Activity. I have to perform different list item click function. Can i use the following method code for it? So how to set a single onItemClickListener for multiple ListViews?
   public void onItemClick(AdapterView<?> adapter, View view, int index, long id)
   { 
       switch(view.getId())
       {
          case <listview1 Id> : //call method 1; break;
          case <listview2 Id> : //call method 2; break;
          case <listview3 Id> : //call method 3; break;
       }
   }
                Set different adapters for different list views. I take two list view for example. So take two adapter for these two. And setOnItemClick(context) will be like as below..
 public void onItemClick(AdapterView<?> adv, View v, int arg2, long arg3) {
    // TODO Auto-generated method stub
    switch(adv.getId()) {
        case R.id.ListView1:
            Toast.makeText(this, "list1", Toast.LENGTH_LONG).show();
            break;
        case R.id.ListView2:
            Toast.makeText(this, "list2", Toast.LENGTH_LONG).show();
            break;
    }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With