0

我在使用 Slidingdrawer 时遇到了一些问题。如何修复它。

主要 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" 
    android:background="@color/white">
    <SlidingDrawer 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@color/black"
    android:handle="@+id/handle"
    android:id="@+id/slideD">
    <Button 
        android:layout_width="60dp" 
        android:layout_height="60dp" 
        android:id="@id/handle" 
        android:background="@drawable/arrow_up"
        />
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
              <Button 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:background="@drawable/ic_launcher"
            >
          </Button>
          <Button 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:background="@drawable/ic_launcher"
            >
          </Button>     
        </LinearLayout>
    </SlidingDrawer>
</LinearLayout>

活动

public class ATDTActivity extends Activity {

    SlidingDrawer slideD;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        slideD = (SlidingDrawer)findViewById(R.id.slideD);
        slideD.setOnDrawerOpenListener(new OnDrawerOpenListener(){
            @Override
            public void onDrawerOpened() {
            slideD.getHandle().setBackgroundResource(R.drawable.arrow_down);
            }
        });
        slideD.setOnDrawerCloseListener(new OnDrawerCloseListener(){
            @Override
            public void onDrawerClosed() {
            sideD.getHandle().setBackgroundResource(R.drawable.arrow_up);
                    }
        });
    }
}

谢谢帮忙!。您的帖子没有太多上下文来解释代码部分;请更清楚地解释您的情况。

4

2 回答 2

1

向 SlidingDrawer 添加内容:

....
<SlidingDrawer
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:content="@+id/content"
        android:handle="@+id/handle"
        android:id="@+id/slideD">
 ........
 <LinearLayout
            android:id="@id/content"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

  ....... 
于 2012-07-23T09:27:16.530 回答
1

甚至不要打扰这堂课

此类在 API 级别 17 中已弃用。

于 2013-03-09T17:49:05.953 回答