I’m going to share a code snippet that you may use to programmatically click a ListView item in your Android app. This will not simply highlight the desired ListView item, but also trigger the onItemClick listener. This code is what I placed in a Fragment’s onLoadFinished() method:
1 2 |
int default_position = 2; listView.performItemClick(listView.getChildAt(default_position), default_position, listView.getItemIdAtPosition(default_position)); |
Simply replace the default_position value with the […]