
<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:orIEntation="horizontal" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:ID="@+ID/frags"> <fragment androID:ID="@+ID/frag_Title" androID:visibility="gone" androID:layout_margintop="?androID:attr/actionbarSize" androID:layout_wIDth="@dimen/Titles_size" androID:layout_height="match_parent" /> <fragment androID:ID="@+ID/frag_content" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" />解决方法 更改< fragment />在xml布局中< FrameLayout />
<FrameLayout androID:ID="@+ID/frag_Title" androID:visibility="gone" androID:layout_margintop="?androID:attr/actionbarSize" androID:layout_wIDth="@dimen/Titles_size" androID:layout_height="match_parent" /> <FrameLayout androID:ID="@+ID/frag_content" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" />
并以编程方式添加片段:
FragmentManager fragmentManager = getFragmentManager()FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();ExampleFragment fragment = new ExampleFragment();fragmentTransaction.replace(R.ID.frag_content,fragment);fragmentTransaction.commit();
但最初阅读this.
总结以上是内存溢出为你收集整理的android – 如何动态更改片段的类全部内容,希望文章能够帮你解决android – 如何动态更改片段的类所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)