Sahan Sahan - 1 year ago 98
Java Question

Check unique list identifier from item on click

guys what's up?
I'm still new to android and creating some testing app.

  • I have two Lists in my view. (Left and Right).

  • List Filled with values.

I trying to add selected list item value to other lists.
For example, If I clicked on an item in a left list. I wanna add selected item to Right list,

implemented OnItemClickListener into my code and OnItemClickListener onItemClick method is firing for both lists.

Any way to identify clicked list in an onItemClick method?
any suggestions are greatly appreciated.

Answer Source

After reading official API. Found a solution. We can get the ID on the selected list.

public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    if(adapterView.getId() =={
        // It's a left list
        // It's a Right list
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download