The problem is that I have two listView
but one itemClick method, if I put a switch, the position on one list is the same than the other list... And by example if I want to open a popup on an item in one list, the item in the same position in the other list gonna do the same thing, and I really don't want, can you help me?
There is the code :
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Object str = parent.getId();
if(str.equals(adapter_todo)){
switch(position){
case 0 :
new AlertDialog.Builder(this).setTitle("test").setMessage("blah blah").setNeutralButton("close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).show();
case 1 :
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
case 7 :
case 8 :
case 9 :
case 10 :
}
}
else if(str.equals(adapter_not_todo)){
switch(position){
case 0 :
new AlertDialog.Builder(this).setTitle("test 2").setMessage("blah blah blah").setNeutralButton("close", new DialogInterface.OnClickListener() {
@Override
pub开发者_如何学Pythonlic void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).show();
case 1 :
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
case 7 :
case 8 :
case 9 :
case 10 :
}
}
}
In onItemClick, call parent.getId() to tell which list view was clicked.
精彩评论