How to resume Fragment from BackStack if exists

前端 未结 6 1040
野的像风
野的像风 2020-11-22 13:29

I am learning how to use fragments. I have three instances of Fragment that are initialized at the top of the class. I am adding the fragment to an activity lik

6条回答
  •  遥遥无期
    2020-11-22 14:32

    Easier solution will be changing this line

    ft.replace(R.id.content_frame, A); to ft.add(R.id.content_frame, A);

    And inside your XML layout please use

      android:background="@color/white"
      android:clickable="true"
      android:focusable="true"
    

    Clickable means that it can be clicked by a pointer device or be tapped by a touch device.

    Focusable means that it can gain the focus from an input device like a keyboard. Input devices like keyboards cannot decide which view to send its input events to based on the inputs itself, so they send them to the view that has focus.

提交回复
热议问题