问题
I am populating listview dynamically i want when activity is created it take the focus to the specific item of the listview. like in facebook app from notification it takes on the specific row of the comments.
回答1:
if your listview extends Activity try :
listviewName.setSelection(positionOfItem);
and if your listview extends ListActivity try :
getListView().setSelection(positionOfItem);
example for my chat application, Listview must be focused at the last row so i just put this code after message displayed
getListView().setSelection(getListAdapter().getCount()-1);
回答2:
Have you tried this:
listView.setSelection(position);
来源:https://stackoverflow.com/questions/17579305/how-to-focus-android-activity-to-the-specific-item-of-the-listview