Attach a Fragment to the Activity

前端 未结 3 1489
野的像风
野的像风 2021-01-07 15:23

I am trying to attach a Fragment to my MainActivity programmatically by using the following code:

@Override
protected void onCreate(Bundle savedInstanceSta         


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 16:23

    first of all your take framelayout in activity_main.after that

    fragmentTransaction.add(R.id.framelayout_id,fragment);

    than its working fine

提交回复
热议问题