MissCoder87
MissCoder87

Reputation: 2669

Getting listview ID name

I'm passing a listview in to an onselect but theres a couple of ways it's called from different listviews. So i'm trying to work out which listview is being clicked.

I thought I could do the following however the string thats returned is like com.myapp.tool/id/32423423c (type thing) instead of lvAssets.

Here is what I've got:

@Override
public void onNumberRowSelect(ListView listview, clsNameID stat) {

    if(listview.getAdapter().toString().equals("lvGenericAssets")){

    } else if(listview.getAdapter().toString().equals("lvAssets")){

    } else {
        Functions.ShowToolTip(getApplicationContext(), 
                              listview.getAdapter().toString());
    }
}

Upvotes: 0

Views: 75

Answers (2)

Emil Adz
Emil Adz

Reputation: 41129

Why wont you just use: list.getId(); if you defined it in the XML file then you should define there an id for you ListView.

If you are doing this from code then you can use the list.setId(); to first set it's id.

Another thing you can do is to add a Tag to your listView: list.setTag("list1"); and latter on distinct this listView using the Tag: list.getTag();

Upvotes: 1

Alexis C.
Alexis C.

Reputation: 93892

As Emil Adz said in first, you can get the id of your list by calling list.getId();

Then use String idList = getResources().getResourceEntryName(id); and you will be able to get the name of the id you have given to your list

Upvotes: 1

Related Questions