Android SlidingDrawer

1

Я пытаюсь поместить скользящий ящик в свою деятельность, используя этот учебник. Мое приложение предназначено для Android 2.1-update1 (API 7). Когда я создаю xml-макет, например:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">

<SlidingDrawer
    android:id="@+id/slidingDrawer"
    android:handle="@+id/drawerHandle"
    android:content="@+id/contentLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

<LinearLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center">
    <EditText android:text="" android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth="100px"/>
    <Spinner android:id="@+id/spinner1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:prompt="@string/strFilter" />
    <Button android:text="Filtriraj" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</LinearLayout>
</SlidingDrawer>
<ScrollView android:layout_height="fill_parent" android:layout_width="fill_parent">
    <TableLayout android:layout_width="fill_parent" android:id="@+id/tableLayout1" android:layout_height="fill_parent" android:orientation="horizontal">
        <TableRow android:id="@+id/tableRow1" android:layout_height="wrap_content" android:baselineAligned="true" android:layout_gravity="center_horizontal" android:clipChildren="true" android:gravity="center_horizontal" android:layout_width="fill_parent" android:layout_margin="3dip">
            <TextView android:clickable="true" android:layout_height="wrap_content" android:text="@string/lblOd" android:id="@+id/textView1" android:layout_gravity="center_horizontal" android:layout_width="fill_parent" android:layout_marginRight="5dip"></TextView>
            <TextView android:clickable="true" android:layout_height="wrap_content" android:id="@+id/textView2" android:text="@string/lblDatum" android:layout_gravity="center_horizontal" android:layout_width="fill_parent" android:drawableLeft="@drawable/arrowdown"></TextView>
            <TextView android:clickable="true" android:layout_height="wrap_content" android:id="@+id/textView3" android:text="@string/lblTekst" android:layout_gravity="center_horizontal" android:layout_width="fill_parent" android:layout_marginLeft="3dip"></TextView>
        </TableRow>
    </TableLayout>
</ScrollView>
</LinearLayout>

У меня возникло исключение при переключении на "дизайн" - графический макет. Ошибка

ClassCastException: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
Exception details are logged in Window > Show View > Error Log
The following classes could not be found: - SlidingDrawer

Что не так с моим кодом?

Теги:
slidingdrawer

3 ответа

0

Полностью квалифицируя имя класса SlidingDrawer (android.widget.SlidingDrawer), разрешил эту проблему для меня. Это, похоже, работает только для 2.1-update1 и выше.

Кроме того, убедитесь, что вы установили дескриптор ящика в действительный дочерний элемент ящика.

0

К сожалению, вы будете разрабатывать/размещать вещи для версии 3.0, когда ваше приложение будет работать на MILLIONS из 2.x устройств.

0

Переключить дизайн на Android 3.0, тогда он работает, что-то вроде ошибки в ADT. Если вы запустите его в эмуляторе, тогда работает код.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню