I\'m facing some difficults when I try to use the performItemClick funcion of the ListView.
All I want to do is to perform a click programatically i
Using the code @sulal proposed, you may place it in onLoadFinished, if you use a LoaderManager. Eg something like
@Override
public void onLoadFinished(Loader loader, Cursor data) {
//....
// mSelectedId keeps the currently selected id
// INVID is an invalid value
if (mSelectedId == INVID) { // nothing selected
// sulal's code
new Handler().post(new Runnable() {
@Override
public void run() {
mList.performItemClick(
mList.getChildAt(mActivePosition),
mActivePosition,
mList.getAdapter().getItemId(mActivePosition));
mSelectedId = mList.getAdapter().getItemId(mActivePosition);
}
});
}
mActivePosition may be 0 (ie position on the first item) or a position kept during eg onPause