In android, how do I dynamically swap a fragment by button click or other event?

后端 未结 2 1197
无人及你
无人及你 2021-01-15 17:29

I\'m stuck at a sore point: fragments.

Here\'s a reference of the layout

\"\"

I\'m trying to swap

相关标签:
2条回答
  • 2021-01-15 18:12

    Android Fragment API let you to make some transactions in it like add new one , delete and replace one with another one that's will help you to build flexible UI design based on your device size ,

    and here some guide for you :

    http://developer.android.com/training/basics/fragments/fragment-ui.html

    http://www.cs.dartmouth.edu/~campbell/cs65/lecture09/lecture09.html

    http://android-er.blogspot.com/2013/04/replace-fragment.html

    and if you facing any problem in code tell me to discuss in it

    0 讨论(0)
  • 2021-01-15 18:17

    There is a call within FragmentTransaction to replace the fragment in the container. You just need to have a designated container hold the place where c and d will go, and then upon button click do something like: getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "FragD");

    0 讨论(0)
提交回复
热议问题