2012-10-22 61 views
0

對於我的應用程序需要創建按鈕組滑動抽屜,但是當我運行的代碼就說明力,收warning..My的Xml樣子滑動抽屜申請退出

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

    <com.measure.sizemesurment2.MyView 
    android:id="@+id/DrawViewId" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    </com.measure.sizemesurment2.MyView > 

    <SlidingDrawer 
     android:id="@+id/drawer" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:handle="@+id/handle" 
     android:content="@+id/content"> 

    <ImageView 
     android:id="@id/handle" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:src="@drawable/drawer"/> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="horizontal" 
     android:gravity="bottom"> 



    <ImageButton 
     android:id="@+id/left" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:onClick="ButtonOnClick"      
     android:src="@drawable/left" /> 

    <ImageButton 
     android:id="@+id/right" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginLeft="40dp" 
     android:onClick="ButtonOnClick"      
     android:src="@drawable/right" /> 

    <ImageButton 
     android:id="@+id/up" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginLeft="80dp" 
     android:onClick="ButtonOnClick"         
     android:src="@drawable/up" /> 

     <ImageButton 
     android:id="@+id/down" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginLeft="120dp" 
     android:onClick="ButtonOnClick"      
     android:src="@drawable/down" /> 

    <Button 
     android:id="@+id/plus" 
     android:layout_width="40dp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginLeft="180dp" 
     android:textSize="20dp" 
     android:onClick="ButtonOnClick"    
     android:text="+" 
     /> 

    <Button 
     android:id="@+id/minus" 
     android:layout_width="40dp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginLeft="220dp" 
     android:textSize="20dp" 
     android:onClick="ButtonOnClick"      
     android:text="-" /> 

    <Button 
     android:id="@+id/ok" 
     android:layout_width="60dp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_marginLeft="260dp" 
     android:textSize="20dp" 
     android:onClick="ButtonOnClick"       
     android:text="OK" /> 
    </RelativeLayout> 
    </SlidingDrawer> 

    </FrameLayout> 

其中MyView的類用於畫布繪製..在上面的XML文件的情況下 是對的...任何幫助將不勝感激.....提前 感謝.....

,這裏是我的logcat

10-22 17:40:17.810: D/dalvikvm(6384): GC_EXTERNAL_ALLOC freed 1K, 44% free 3371K/5959K, external 1801K/1925K, paused 31ms 
10-22 17:40:17.860: I/Camera(6384): handleMessage: 16 
10-22 17:40:17.952: I/Camera(6384): handleMessage: 16 
10-22 17:40:17.979: I/Sample::Activity(6384): onPause 
10-22 17:40:17.979: I/Sample::SurfaceView(6384): releaseCamera 
10-22 17:40:18.017: D/IPCThreadState(6384): [DN #5] BR_CLEAR_DEATH_NOTIFICATION_DONE cookie 0x1772a0 
10-22 17:40:18.193: D/AndroidRuntime(6384): Shutting down VM 
10-22 17:40:18.194: W/dalvikvm(6384): threadid=1: thread exiting with uncaught exception (group=0x4001b6a8) 
10-22 17:40:18.200: E/AndroidRuntime(6384): FATAL EXCEPTION: main 
10-22 17:40:18.200: E/AndroidRuntime(6384): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.measure.sizemesurment2/com.measure.sizemesurment2.MesureSizeActivity}: java.lang.IllegalArgumentException: The content attribute is must refer to an existing child. 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1740) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1759) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.app.ActivityThread.access$1500(ActivityThread.java:155) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:999) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.os.Handler.dispatchMessage(Handler.java:130) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.os.Looper.loop(SourceFile:351) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.app.ActivityThread.main(ActivityThread.java:3826) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at java.lang.reflect.Method.invokeNative(Native Method) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at java.lang.reflect.Method.invoke(Method.java:538) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at dalvik.system.NativeStart.main(Native Method) 
10-22 17:40:18.200: E/AndroidRuntime(6384): Caused by: java.lang.IllegalArgumentException: The content attribute is must refer to an existing child. 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.widget.SlidingDrawer.onFinishInflate(SlidingDrawer.java:277) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:662) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:657) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.view.LayoutInflater.inflate(LayoutInflater.java:439) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.view.LayoutInflater.inflate(LayoutInflater.java:351) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.view.LayoutInflater.inflate(LayoutInflater.java:307) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:253) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.app.Activity.setContentView(Activity.java:1703) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at com.measure.sizemesurment2.MesureSizeActivity.onCreate(MesureSizeActivity.java:55) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1704) 
10-22 17:40:18.200: E/AndroidRuntime(6384):  ... 11 more 
10-22 17:40:18.203: E/dalvikvm(6384): [DVM] mmap return base = 45374000 
10-22 17:40:18.246: D/dalvikvm(6384): GC_CONCURRENT freed 442K, 48% free 3139K/6023K, external 1206K/1925K, paused 2ms+17ms 
+0

logcat中需要的類。 –

+0

-1不發佈堆棧跟蹤。 – njzk2

回答

3

你需要聲明

android:id="@+id/content" 

爲RelativeLayout的在你的SlidingDrawer。 你可以從here 找到更多關於SlidingDrawer的信息如果它不起作用,那麼,在這裏發佈logcat。

+0

嗨,感謝您的回覆我給了我的相對佈局的ID,現在它的工作...... – Haris

0

另外,還要確保在com.measure.sizemesurment2.MyView你有下面的構造

public MyView(Context context, AttributeSet attrs) { 
super(context, attrs); 
    //your code 
} 

感謝&問候, Rajamanickem.S

+0

是的,它沒有抽屜工作.... – Haris

+0

看看下面的例子中的例子... http ://www.java2s.com/Code/Android/UI/SethandleandcontentforSlidingDrawer.htm – Rajamanickem

+0

嗨,感謝您的回覆..... – Haris