猿问

安卓开发用新版eclipse怎么解决fragment.xml

安卓开发用新版eclipse怎么解决fragment.xml


波斯汪
浏览 353回答 2
2回答

慕沐林林

安卓开发中fragment在xml布局中写法如下:1、layout.xml代码如下:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:background="#555555">&nbsp; &nbsp; <fragment class="com.androidbook.fragments.bard.TitlesFragment"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/titles"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_weight="1"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="0px"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:background="#00550033" />&nbsp; &nbsp; <FrameLayout &nbsp; android:id="@+id/details"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;android:layout_weight="2"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="0px"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="match_parent" /></LinearLayout>程序运行图片如下:<fragment> 标记只是此布局中的一个占位符,不能将子标记放在<fragment> 标记内<fragment>标记的class特性指定应用程序 的标题的扩展类, 也就是必须写一个类 继承Fragment, &nbsp;碎片拥有自己的视图层次结构,该结构将由碎片在以后创建。
随时随地看视频慕课网APP

相关分类

Android
我要回答