用于布局的Android抽象活动
是否可以有一个定义布局(导航等)的抽象活动和一个定义活动内容的子类?xml布局文件怎么样 我的意思是我有一个xml用于布局的Android抽象活动,android,android-layout,Android,Android Layout,是否可以有一个定义布局(导航等)的抽象活动和一个定义活动内容的子类?xml布局文件怎么样 我的意思是我有一个xml <xxx.DefaultNavigationDrawer xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/navigation_drawer" android:layout_width="match_parent" android:layout_height="match
<xxx.DefaultNavigationDrawer xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/navigation_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Fragment contents go in here -->
</FrameLayout>
<ListView
android:id="@+id/navigation_drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_weight="1"
android:background="@drawable/calendar"
android:choiceMode="singleChoice"
android:divider="@color/calendar_divider"
android:dividerHeight="1dp" />
</xxx.DefaultNavigationDrawer>
我希望我所有的活动都有这样的布局。唯一会改变的是标记。您可以在基本
活动类中设置布局,然后在派生活动的onCreate中调用FragmentManager.replace()
用片段替换FrameLayout
的内容。我必须使用片段吗?既然你想插入片段,那你怎么能避免使用片段呢?我想问的是是否还有其他方法:)。你的回答完全可以。