Android: get position of item in a listview given its id:

后端 未结 4 442
Happy的楠姐
Happy的楠姐 2021-01-11 19:46

getItemIdAtPosition() is a function in android used to get the id of an item in a list view given its position

is there any way of doing the reverse, i.

4条回答
  •  借酒劲吻你
    2021-01-11 20:20

    it's too late to answer but for benefit...
    for example if you have listview and you want to get id with click listener you can get it by >>

    cListview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
    
    
              @Override
                        public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
                  // for id or any informations
    
                                    itemID = String.valueOf(catList.get(position).getItemID());
    
    // for name or any informations
    
                                        itemName = String.valueOf(catList.get(position).getItemName());
    

提交回复
热议问题