2

我一直在搞乱 android,而且我已经使用DrawerLayoutAndroid Support Library v4 构建了用户界面。

我的大学老师强迫我们使用 API Level 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.

(这个是在我将抽屉的内容值更改为@+id/content 后引发的)

这是我期待达到的结果。

导航抽屉组件

关于如何解决它的任何想法?

我有这个 UI 在 API 17 上完美运行,在 DrawerLayout 上的 ListView 上有一个自定义 ListAdapter(来自 android.support.v4.widget.DrawerLayout),但它不适用于较低的 API 级别。

4

1 回答 1

1

您正在使用 NavigationDrawer,它在 android中使用ActionBar组件。这仅适用于 3.0 及更高版本。所以你需要在你的应用程序中删除 ActionBar 代码并尝试你自己的标题代码。

否则将actionbar的代码更改为ActionBarCompat,这是一个用于处理低版本actionbar的库,实现非常简单,只需按照url

于 2013-09-20T05:42:38.133 回答