Tag: 导航抽屉

导航抽屉:如何在启动时设置选定的项目?

我的代码完美地工作:每次导航抽屉中的项目被点击时,项目被选中。 当然,我想用默认片段(home)启动应用程序,但是Navigation Drawer没有select该项目。 如何以编程方式select该项目? public class BaseApp extends AppCompatActivity { //Defining Variables protected String LOGTAG = "LOGDEBUG"; protected Toolbar toolbar; protected NavigationView navigationView; protected DrawerLayout drawerLayout; private DateManager db = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.base_layout); navigationView = (NavigationView) findViewById(R.id.navigation_view); // set the home/dashboard at startup FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.frame, new […]