对于我的应用程序,我需要为按钮组创建一个滑动抽屉,但是当我运行代码时,它会显示强制关闭警告。我的 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 文件的情况下是正确的......任何帮助将不胜感激......提前致谢......
这是我的日志猫
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