我正在开发一个遥控器的用户界面,但我遇到了下面的崩溃,因为我是Android的新手我不知道发生了什么,试图寻找类似的问题,没有响铃如果它是重复的话,请原谅我。
这是堆栈跟踪:
04-09 16:10:04.483: E/AndroidRuntime(1420): FATAL EXCEPTION: main
04-09 16:10:04.483: E/AndroidRuntime(1420): Process: com.example.connecttoserver, PID: 1420
04-09 16:10:04.483: E/AndroidRuntime(1420): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.connecttoserver/com.example.connecttoserver.SecondScreen}: android.view.InflateException: Binary XML file line #93: Error inflating class <unknown>
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.app.ActivityThread.access$800(ActivityThread.java:144)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.os.Handler.dispatchMessage(Handler.java:102)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.os.Looper.loop(Looper.java:135)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.app.ActivityThread.main(ActivityThread.java:5221)
04-09 16:10:04.483: E/AndroidRuntime(1420): at java.lang.reflect.Method.invoke(Native Method)
04-09 16:10:04.483: E/AndroidRuntime(1420): at java.lang.reflect.Method.invoke(Method.java:372)
04-09 16:10:04.483: E/AndroidRuntime(1420): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
04-09 16:10:04.483: E/AndroidRuntime(1420): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
04-09 16:10:04.483: E/AndroidRuntime(1420): Caused by: android.view.InflateException: Binary XML file line #93: Error inflating class <unknown>
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.view.LayoutInflater.createView(LayoutInflater.java:633)
04-09 16:10:04.483: E/AndroidRuntime(1420): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
04-09 16:10:04.483: E/AndroidRuntime(1420): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.app.Activity.setContentView(Activity.java:2144)
04-09 16:10:04.483: E/AndroidRuntime(1420): at com.example.connecttoserver.SecondScreen.onCreate(SecondScreen.java:33)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.app.Activity.performCreate(Activity.java:5933)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
04-09 16:10:04.483: E/AndroidRuntime(1420): ... 10 more
04-09 16:10:04.483: E/AndroidRuntime(1420): Caused by: java.lang.reflect.InvocationTargetException
04-09 16:10:04.483: E/AndroidRuntime(1420): at java.lang.reflect.Constructor.newInstance(Native Method)
04-09 16:10:04.483: E/AndroidRuntime(1420): at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.view.LayoutInflater.createView(LayoutInflater.java:607)
04-09 16:10:04.483: E/AndroidRuntime(1420): ... 23 more
04-09 16:10:04.483: E/AndroidRuntime(1420): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x12/d=0x0 a=2 r=0x7f090051}
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.content.res.Resources.loadColorStateList(Resources.java:2526)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.content.res.TypedArray.getColorStateList(TypedArray.java:427)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.widget.TextView.<init>(TextView.java:987)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.widget.Button.<init>(Button.java:111)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.widget.Button.<init>(Button.java:107)
04-09 16:10:04.483: E/AndroidRuntime(1420): at android.widget.Button.<init>(Button.java:103)
04-09 16:10:04.483: E/AndroidRuntime(1420): ... 26 more
这是XML文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingLeft="20dp" >
<ImageButton
android:id="@+id/power"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:src="@drawable/power" />
<Button
android:id="@+id/Button9"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignBottom="@+id/Button8"
android:layout_alignLeft="@+id/Button6"
android:layout_alignTop="@+id/Button8"
android:text="9" />
<Button
android:id="@+id/Button7"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_below="@+id/Button4"
android:layout_marginTop="25dp"
android:layout_toLeftOf="@+id/button2"
android:text="7" />
<Button
android:id="@+id/main_menu"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignLeft="@+id/Button7"
android:layout_below="@+id/Button7"
android:layout_marginTop="20dp"
android:text="Menu"
android:textSize="8sp" />
<Button
android:id="@+id/zap_b"
android:layout_width="35dp"
android:layout_height="50dp"
android:layout_alignLeft="@+id/zap_f"
android:layout_below="@+id/zap_f"
android:layout_marginTop="14dp"
android:text="P-"
android:textSize="8sp" />
<Button
android:id="@+id/vol_l"
android:layout_width="35dp"
android:layout_height="50dp"
android:layout_alignBottom="@+id/zap_b"
android:layout_alignLeft="@+id/vol_h"
android:layout_alignTop="@+id/zap_b"
android:text="V-"
android:textSize="8sp" />
<Button
android:id="@+id/zap_f"
android:layout_width="35dp"
android:layout_height="50dp"
android:layout_alignLeft="@+id/main_menu"
android:layout_below="@+id/main_menu"
android:text="P+"
android:textSize="8sp" />
<Button
android:id="@+id/up"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_alignBaseline="@+id/zap_f"
android:layout_alignBottom="@+id/zap_f"
android:layout_toLeftOf="@+id/back"
android:text="^"
android:textSize="15sp" />
<Button
android:id="@+id/left"
android:layout_width="30dp"
android:layout_height="60dp"
android:layout_above="@+id/down"
android:layout_toLeftOf="@+id/down"
android:text="@string/left"
android:textSize="15sp" />
<Button
android:id="@+id/down"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_alignBaseline="@+id/zap_b"
android:layout_alignBottom="@+id/zap_b"
android:layout_toLeftOf="@+id/back"
android:text="\\/"
android:textColor="@id/back"
android:textSize="8sp" />
<Button
android:id="@+id/vol_h"
android:layout_width="35dp"
android:layout_height="50dp"
android:layout_alignBaseline="@+id/up"
android:layout_alignBottom="@+id/up"
android:layout_marginLeft="18dp"
android:layout_toRightOf="@+id/back"
android:text="V+"
android:textSize="8sp" />
<Button
android:id="@+id/button1"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignLeft="@+id/power"
android:layout_below="@+id/power"
android:layout_marginTop="20dp"
android:text="1" />
<Button
android:id="@+id/Button4"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:layout_marginTop="26dp"
android:text="4" />
<Button
android:id="@+id/back"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignRight="@+id/Button9"
android:layout_alignTop="@+id/Button0"
android:text="Back"
android:textSize="8sp" />
<Button
android:id="@+id/Button0"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignBaseline="@+id/main_menu"
android:layout_alignBottom="@+id/main_menu"
android:layout_alignLeft="@+id/Button8"
android:text="0" />
<Button
android:id="@+id/Button6"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignBaseline="@+id/Button5"
android:layout_alignBottom="@+id/Button5"
android:layout_marginLeft="99dp"
android:layout_toRightOf="@+id/main_menu"
android:text="6" />
<Button
android:id="@+id/Button8"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignBaseline="@+id/Button7"
android:layout_alignBottom="@+id/Button7"
android:layout_toRightOf="@+id/left"
android:text="8" />
<Button
android:id="@+id/Button3"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_above="@+id/Button4"
android:layout_alignLeft="@+id/Button6"
android:text="3" />
<Button
android:id="@+id/Button2"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_above="@+id/Button4"
android:layout_toRightOf="@+id/left"
android:text="2" />
<Button
android:id="@+id/Button5"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_above="@+id/Button7"
android:layout_alignLeft="@+id/Button8"
android:text="5" />
<Button
android:id="@+id/right"
android:layout_width="30dp"
android:layout_height="60dp"
android:layout_alignBaseline="@+id/left"
android:layout_alignBottom="@+id/left"
android:layout_alignLeft="@+id/Button9"
android:text=">"
android:textSize="15sp" />
<Button
android:id="@+id/Ok"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignBaseline="@+id/right"
android:layout_alignBottom="@+id/right"
android:layout_toLeftOf="@+id/back"
android:text="OK"
android:textSize="8sp" />
答案 0 :(得分:2)
检查
android:textColor =“@ id / back”它无效
<Button
android:id="@+id/down"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_alignBaseline="@+id/zap_b"
android:layout_alignBottom="@+id/zap_b"
android:layout_toLeftOf="@+id/back"
android:text="\\/"
android:textColor="@color/anycolor"
android:textSize="8sp" />
答案 1 :(得分:0)
此外
<Button
android:id="@+id/Button7"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_below="@+id/Button4"
android:layout_marginTop="25dp"
android:layout_toLeftOf="@+id/button2"
android:text="7" />
行:android:layout_toLeftOf =“@ + id / button2”没有意义... id / button2没有在任何地方定义