Android force Fragment to rebuild View

后端 未结 2 1170
野性不改
野性不改 2021-01-04 04:12

I have a simple app that has two fragments and when in landscape mode, both fragments are shown side by side and in portrait I show Fragment A and then if they select an opt

2条回答
  •  太阳男子
    2021-01-04 04:59

    if the user selects a menu option I want to refresh or redraw the View that is associated with Fragment B and can’t understand how to make this work

    In onOptionsItemSelected(), have the activity call a method on the fragment that causes it to update its widgets with the new content. Or, have the activity execute a FragmentTransaction to replace the fragment (if the fragment was originally set up via a FragmentTransaction).

提交回复
热议问题