I have following issue: I have a ListView.If you click on a row, My list is reloaded and a button is added on the row. No Problem till now… but: After adding button i want the ListView (after its reload) to select the just edited (or added) row. I want selected row(the row on which button is added) remain highlighted after reload list.
Any suggestion or sample code would be appreciated.
Thanks
Have you tried to use
setSelection(position)?You might have to use the following code :
Update :
Try the XML attributes
android:listSelectorandandroid:drawSelectorOnTop(see the doc) to highlight the selected item.If it does not work as you want, you can create a custom
Adapterwith an int attribute named selectedPosition, pass the position of the selected item to thisAdapterand callnotifyDataSetChangedin the methodOnItemClick, and in theAdapter, change theViewreturned bygetViewif the position equals selectedPosition.