我将ActionBarSherlock与SherlockNavigationDrawer一起使用
默认 fragment_main_layout.xml 是
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:scrollbarStyle="outsideOverlay">
<TextView android:id="@+id/content_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/description"
android:textAppearance="?android:attr/textAppearanceMedium"/>
</ScrollView>
<!-- android:layout_gravity="left" tells DrawerLayout to treat
this as a sliding drawer on the left side. The drawer is
given a fixed width in dp and extends the full height of
the container. A solid background is used for contrast
with the content view. -->
<ListView android:id="@+id/left_drawer"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@android:color/white"/>
我需要在另一个列表视图中显示TextView。为了使自己清楚,我需要用户按导航抽屉,从left_drawer中选择一个选项,并在主内容窗口中显示一个列表视图而不是textview。
我做了一些实验,但是它们导致与两个列表视图冲突(有时没有填充left_drawer或相反,或只显示第二个listview中的第一个字段)
答案 0 :(得分:0)
自己修理
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay">
<ListView android:id="@+id/main_content_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"/>
<TextView android:id="@+id/content_text"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/description"
android:textAppearance="?android:attr/textAppearanceMedium"/>
</RelativeLayout>
<!-- android:layout_gravity="left" tells DrawerLayout to treat
this as a sliding drawer on the left side. The drawer is
given a fixed width in dp and extends the full height of
the container. A solid background is used for contrast
with the content view. -->
<ListView android:id="@+id/left_drawer"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@android:color/white"/>
将ScrollView更改为RelativeLayout,添加了新的listview,其中包含id:main_content_list