在Android BottomNavigationView中设置选定的项目 [英] Set selected item in Android BottomNavigationView
问题描述
我正在使用支持库中的新版android.support.design.widget.BottomNavigationView
.
如何通过代码设置当前选择?我意识到,旋转屏幕后,选择项又变回了第一项.当然,如果有人告诉我,这也将有助于如何在onPause
函数中保存" BottomNavigationView
的当前状态以及如何在onResume
中还原它.
I am using the new android.support.design.widget.BottomNavigationView
from the support library.
How can I set the current selection from code? I realized, that the selection is changed back to the first item, after rotating the screen. Of course it would also help, if someone could tell me, how to "save" the current state of the BottomNavigationView
in the onPause
function and how to restore it in onResume
.
谢谢!
推荐答案
似乎要在SupportLibrary 25.1.0中修复:) 似乎固定的是,旋转屏幕时保存了选择的状态.
Seems to be fixed in SupportLibrary 25.1.0 :) It seems to be fixed, that the state of the selection is saved, when rotating the screen.
这篇关于在Android BottomNavigationView中设置选定的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!