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

前端 未结 8 522
鱼传尺愫
鱼传尺愫 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:31

    just add this code in onCreate method:

    FragmentTransaction ftrans = getFragmentManager().beginTransaction();
    ftrans.replace(R.id.container, ).commit();
    

    Work for me !

提交回复
热议问题