android侧边栏导航,不使用片段

时间:2012-05-10 12:00:28

标签: android android-layout

我想创建一个左侧边栏不会在活动过渡之间发生变化的活动(例如ios中的拆分视图)。似乎我可以用片段做到这一点,但我需要添加对HoneyComb之前的设备的支持。

我尝试使用类似下面的布局。

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
<LinearLayout android:layout_width="320dip"
     android:layout_height="match_parent"
     android:id="@+id/navLay"
    >
 <ListView
         android:id="@+id/navList"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" >
     </ListView>

 </LinearLayout>
  <LinearLayout 
     android:layout_width="wrap_content"
     android:layout_height="match_parent"
     android:id="@+id/contentLay"
     ><ListView
      android:id="@+id/contentList"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" >
  </ListView>
 </LinearLayout>
</LinearLayout>

但是第一个列表也在活动过渡时更新。我想要注意,除了右侧列表的数据源不同之外,活动是相同的活动。因此,如果我可以在导航时保存左侧导航栏的状态和内容,那将是非常好的。任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:2)

查看提供向后兼容性类的Support Package,还包括Fragment类。

答案 1 :(得分:1)

  

似乎我可以使用片段执行此操作,但我需要添加对HoneyComb之前的设备的支持。

您可以在这些设备上使用片段和一些新API。只需使用support package