Custom Arrayadapter Onclick Position & Row Highlight
I have created a custom ArrayList which is working as it should barring an issue with the onClick. I orginally had the ArrayList highlight the selected row in red when the user cli
Solution 1:
ListActvity has its own way to manage cell click.
protectedvoidonListItemClick(ListView l, View v, int position, long id)
This method will be called when you click on an row of the ListView
. As you can see the second paramter is the position
you need
Solution 2:
try this...
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
onClick(...)
{
convertView.parent().setSelection(position); <---
}
}
Solution 3:
I had a similar problem with custom listViews and Array adapters..
for me the android:listSelector
did not work properly so i used android:Background
instead
where i defined states selected, highlighted etc....At the end to achieve certain visual effects i had to use a combination of both, probably not the best solution but works perfectly.
Post a Comment for "Custom Arrayadapter Onclick Position & Row Highlight"