我使用 android 有一段时间了,我已经使用 Android 支持库 v4 中的 DrawerLayout
构建了用户界面。
我的大学老师强制我们使用 API 级别 10 来构建我们的应用程序,所以我就是这么做的。
我正在尝试构建一个内部有 ListView 的 SlidingDrawer,但我找不到正确的方法。以下代码导致两个错误
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/details"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<SlidingDrawer
android:id="@+id/slidingDrawerShowMore"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:topOffset="132dip"
android:handle="@+id/handle"
android:content="@+id/handle">
<ImageView
android:id="@id/handle"
android:layout_width="88dip"
android:layout_height="44dip" />
</SlidingDrawer>
错误信息:
Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
和
Exception raised during rendering: The content attribute is must refer to an existing child.
(这个是在我把drawer的content值改成@+id/content后引发的)
这是我期待实现的结果。
关于如何解决它的任何想法?
我让这个 UI 在 API 17 上完美运行,在 DrawerLayout 的 ListView 上有一个自定义 ListAdapter(来自 android.support.v4.widget.DrawerLayout),但它不适用于较低的 API 级别。
最佳答案
您正在使用 NavigationDrawer,它使用 ActionBar安卓中的组件。这仅适用于 3.0 及更高版本。所以你需要在你的应用程序中删除 ActionBar 代码并尝试你自己的标题代码。
否则将actionbar的代码改为ActionBarCompat这是一个用于在低版本中处理 actionbar 的库,实现起来非常简单,只需按照 url
关于android - 我如何在 Android API 级别 10 上实现带有 ListView 的 SlidingDrawer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18907668/