How to refer to the original position of a list item when text filter is enabled?

后端 未结 4 892
甜味超标
甜味超标 2021-01-15 13:58

When I use edit text to filter the items, the list positions get all messed up and the items no longer call the proper intent. Any help is appreciated

lv.se         


        
4条回答
  •  星月不相逢
    2021-01-15 14:16

     flashsearchList.setOnItemClickListener(new OnItemClickListener() {
    
            @Override 
            public void onItemClick(AdapterView parent, View view,
                    int position, long id) {
                Integer temp=flashSearchNameMap.get(adapter.getItem(position));
    
                navigateSearch(temp); 
    
    
    
            }
        }); 
    

    (adapter.getItem(position) will return you the exact list name and in flashSearchNameMap i have stored names and position at beginning from oncreate before applying filtering.So you can get exact position by this

提交回复
热议问题