Android Master Detail Flow - Select first item in list on tablet only

耗尽温柔 提交于 2019-12-04 14:41:48

You could resolve this by removing the onListItemClick(...) call in the onStart(...) of ItemListFragment and instead adding this below snippet to the end of setActivateOnItemClick(...):

    // If on dual-pane view, pre-select the first item from the chapter list
    if (activateOnItemClick && mActivatedPosition == ListView.INVALID_POSITION) {
        getListView().performItemClick(getListView(), 0, getListView().getItemIdAtPosition(0));
    }

Also, add this one line of code if it is not already there in onListItemClick(...) in ItemListFragment:

    mActivatedPosition = position;

Please check the diff on the file ChapterListFragment from these commits yesterday on my GH repo to get a little more context to my solution - https://github.com/floydpink/BhagavadGita/compare/047de35c39f01c6341a7f677aa5b7cc47a7144a3...b1b45d15cd68290e2ebe909ca920bd7aefd2805e#diff-1

Hope this helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!