Android - ListView - performItemClick

前端 未结 24 1285
清歌不尽
清歌不尽 2020-11-29 03:10

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

24条回答
  •  隐瞒了意图╮
    2020-11-29 04:10

    This works best for me. Run this on the main thread.

    new Handler().post(new Runnable() {
        @Override
        public void run() {
            mList.performItemClick(
                    mList.getChildAt(mActivePosition),
                    mActivePosition,
                    mList.getAdapter().getItemId(mActivePosition));
        }
    });
    

    This is similar to Arun Jose's answer, but it will queue a message to the main thread to give the ListView some time to initiate.

提交回复
热议问题