本文介绍了在android中,如何通过按钮单击或其他事件动态交换片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我陷在一个痛处:碎片.

I'm stuck at a sore point: fragments.

这里是布局的参考

单击按钮后,我试图用片段D交换片段C.片段A和B需要保留而不刷新.

I'm trying to swap out fragment C with fragment D upon button click. Fragment A and B needs to stay without refreshing.

好像我停止让它加载片段而不丢弃旧片段,导致片段D出现在片段C上方,而C仍然可见.

It looks like I stopped at having it load a fragment without throwing away the old fragment, leading to fragment D appearing above fragment C, with C still visible.

我该怎么做?

推荐答案

Android Fragment API允许您在其中进行一些事务,例如添加新事务,删除事务并用另一事务替换,这将帮助您基于基础构建灵活的UI设计在您的设备尺寸上,

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/fragment/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

这篇关于在android中,如何通过按钮单击或其他事件动态交换片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:01