0

我想创建一个左侧有侧边栏的活动,在活动转换之间没有变化(如 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>

但是第一个列表也会在活动转换时更新。我想指出,除了右列表的数据源不同之外,活动是相同的活动。所以如果我可以在导航时保存左侧导航栏的状态和内容,那就太好了。任何帮助将不胜感激。

4

2 回答 2

2

Take a look at Support Package which provides classes for backward compatibility, and includes Fragment class also.

于 2012-05-10T12:04:14.473 回答
1

It seems that I can do this with fragments but I need to add support for devices that is prior to HoneyComb.

You can use fragments and some new APIs on those devices. Just use support package.

于 2012-05-10T12:04:12.723 回答