2012-07-23 55 views
0

當我使用Slidingdrawer時遇到了一些問題。如何解決它。膨脹類錯誤android.widget.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); 
        } 
     }); 
    } 
} 

感謝幫助! 您的帖子沒有太多的上下文來解釋代碼段;請更清楚地解釋你的情況。

回答

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"> 

    ....... 
1

甚至不要與此class打擾。

這個類是在API級別棄用17.

相關問題