After a tremendous amount of time searching in here, and everywhere else I am hopeless to find a solution.
So here is my problem.
I have created a list-view and on top of that I added a search-bar.
When I use the search-bar, to filter the results... when I click on item 7, instead of opening the specific clicked activity i.e. 7, it always starts from the first one.
I am looking forward to your help guys; because I need it!
I think you cant find correct position on listview item click. so u can use one textview with visibility="Gone" and insert the position in that textview in every row. now u can easily access position while clicking on item with the value of textview which shows perfect position. Hope it works. Thanx
Custom adapter Class:
As from my previously answered question here, you have to override the
getItem(position)
method in yourCustomAdapter
. You are setting theonItemClick
somewhat correctly but the list adapter doesn't know what exactly it's getting fromgetItem(position)
.EDIT (details): You need to add something like this in your custom adapter -
You should already have the
list
in your custom adapter. If not, you can add a list reference to yourCustomAdapter
:Then setting it using a setter in your
Group
activity:The problem is that Adapter is populated once but with search results it gets overViewed by the searched items so on clicking it refers to the original items of list instead of the filtered list once , so we have to use the filtered lists' positions instead of the original one, i also faced this problem, try this:
In your listView.setOnItemClickListener