简体   繁体   中英

How to identify which list view item is clicked when using same list view layout for multiple lists in android?

I have created a single dialog box in one function, and passing list view layout resource in it, to make listview inside dialog. I have set onClickItemListener in it to get the listener of what item is clicked. As i am using same dialog box with same list view, having different values. I want to identify which listview is clicked by some unique key. I tried looking in google but didn't find any solution. I am reusing same dialog code with list view for multiple functionality. One time i am showing category, but other time showing type and selecting one using click on item, but not able to identify which click is for type and which one for category.

Please guide me in right direction. Can i set some parameter in listview and read it when item is clicked to parse and get to know which listview is clicked?

As we pass adaptor to the list view and adaptor can give value based on position by overriding function

@Override
public String getItem(int position) {
    return this.listItems[position];
}

I have saved a extra parameter which defines category which this list view belongs and asked adaptor to tell me back in activity from which category this list belong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM