android - AdapterView.OnItemClickListener with more ListView -


i have 2 listview on single fragment , wonder if can set both same class implements adapterview.onitemclicklistener.

i mean, android documentation says:

public abstract void onitemclick (adapterview<?> parent, view view, int position, long id)  added in api level 1 callback method invoked when item in adapterview has been clicked.  implementers can call getitematposition(position) if need access data associated selected item.  parameters parent  adapterview click happened. view    view within adapterview clicked (this view provided adapter) position    position of view in adapter. id  row id of item clicked. 

so suppose can choose different listview invoked onclick parent (adapterview click happened)..

now how can identify listview? there way swicth / case? or need create different class (can anonymous know) implements onitemclicklistener , set differents listview differents adapterview.onitemclicklistener?

ok resolved:

private class myclass implements adapterview.onitemclicklistener {      @override     public void onitemclick(adapterview<?> parent, view view, int position,             long id) {         // todo auto-generated method stub          switch(parent.getid()) {         case r.id.listview1:                         break;         case r.id.listview2:             break;         }     } } 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -