How to select the first item in a navigation drawer and open a fragment on application start

前端 未结 8 507
鱼传尺愫
鱼传尺愫 2021-02-04 05:32

I have created MainActivity with NavigationView. When Activity is opened I want to automatically select the first item in the navigation d

8条回答
  •  孤城傲影
    2021-02-04 06:22

    Add android:checked="true" to your first menu item.

    And manually select one item, using

    getSupportFragmentManager().beginTransaction().replace(R.id.frame, postListFragment).commit();
    

    to open fragment.

提交回复
热议问题