【问题标题】:android sidebar navigation without using fragments不使用片段的android侧边栏导航
【发布时间】:2012-05-10 20:04:14
【问题描述】:

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

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

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

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

    【讨论】:

    • 在不使用支持包的情况下我还有其他选择吗?
    • Fragment 将是最简单的方法。如果你真的想避免它(我很想知道为什么),那么你可以使用Tab Layout 并检查如何create vertical tab bar
    【解决方案2】:

    似乎我可以使用片段来做到这一点,但我需要添加对 HoneyComb 之前的设备的支持。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-29
      • 1970-01-01
      相关资源
      最近更新 更多