我一直在使用gitHub上的ConnectDotView课程,一切顺利,直到我尝试通过我在 ConnectDotsView中设置的界面设置 newScoreCounter 类。活动在运行时崩溃。它甚至没有出现。我不知道我搞砸了哪里。这是我的活动:
activity_points.xml :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainRelative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.jutt.dotbot.PointsDrawerActivity" >
<com.jutt.dotbot.ConnectDotsView
android:id="@+id/gfxImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:background="@drawable/m_tsnake_tree" />
<TextView
android:id="@+id/tvHighScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tv2"
android:layout_marginLeft="22dp"
android:layout_toRightOf="@+id/tv2"
android:text="0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tvNewScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/tv1"
android:layout_alignBottom="@+id/tv1"
android:layout_alignLeft="@+id/tvHighScore"
android:text="0"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/tv2"
android:layout_below="@+id/tvHighScore"
android:text="New Score:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvNote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Complete before time run out"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/tvNote"
android:layout_marginTop="16dp"
android:text="HighScore :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/bTimer"
android:layout_width="80dp"
android:layout_height="60dp"
android:layout_alignBottom="@+id/tvNewScore"
android:layout_alignParentRight="true"
android:clickable="false"
android:background="@style/Widget.AppCompat.Button.Small"
android:text="0" />
</RelativeLayout>
logcat的:
07-07 23:28:45.557: I/jdwp(7735): Ignoring second debugger -- accepting and dropping
07-07 23:28:45.787: I/Choreographer(7735): Skipped 45 frames! The application may be doing too much work on its main thread.
07-07 23:28:53.457: D/dalvikvm(7735): GC_FOR_ALLOC freed 56K, 27% free 2745K/3724K, paused 0ms, total 0ms
07-07 23:28:53.477: I/dalvikvm-heap(7735): Grow heap (frag case) to 12.836MB for 10618892-byte allocation
07-07 23:28:53.487: D/dalvikvm(7735): GC_FOR_ALLOC freed <1K, 7% free 13115K/14096K, paused 10ms, total 10ms
07-07 23:28:53.507: D/AndroidRuntime(7735): Shutting down VM
07-07 23:28:53.507: W/dalvikvm(7735): threadid=1: thread exiting with uncaught exception (group=0x64d3ab20)
07-07 23:28:53.507: D/AndroidRuntime(7735): procName from cmdline: com.jutt.dotbot
07-07 23:28:53.507: E/AndroidRuntime(7735): in writeCrashedAppName, pkgName :com.jutt.dotbot
07-07 23:28:53.507: D/AndroidRuntime(7735): file written successfully with content: com.jutt.dotbot StringBuffer : ;com.jutt.dotbot
07-07 23:28:53.517: I/Process(7735): Sending signal. PID: 7735 SIG: 9
07-07 23:28:53.517: E/AndroidRuntime(7735): FATAL EXCEPTION: main
07-07 23:28:53.517: E/AndroidRuntime(7735): Process: com.jutt.dotbot, PID: 7735
07-07 23:28:53.517: E/AndroidRuntime(7735): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jutt.dotbot/com.jutt.dotbot.PointsDrawerActivity}: android.view.InflateException: Binary XML file line #65: Error inflating class <unknown>
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.os.Handler.dispatchMessage(Handler.java:102)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.os.Looper.loop(Looper.java:136)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.app.ActivityThread.main(ActivityThread.java:5021)
07-07 23:28:53.517: E/AndroidRuntime(7735): at java.lang.reflect.Method.invokeNative(Native Method)
07-07 23:28:53.517: E/AndroidRuntime(7735): at java.lang.reflect.Method.invoke(Method.java:515)
07-07 23:28:53.517: E/AndroidRuntime(7735): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
07-07 23:28:53.517: E/AndroidRuntime(7735): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
07-07 23:28:53.517: E/AndroidRuntime(7735): at dalvik.system.NativeStart.main(Native Method)
07-07 23:28:53.517: E/AndroidRuntime(7735): Caused by: android.view.InflateException: Binary XML file line #65: Error inflating class <unknown>
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
07-07 23:28:53.517: E/AndroidRuntime(7735): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
07-07 23:28:53.517: E/AndroidRuntime(7735): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.app.Activity.setContentView(Activity.java:1929)
07-07 23:28:53.517: E/AndroidRuntime(7735): at com.jutt.dotbot.PointsDrawerActivity.onCreate(PointsDrawerActivity.java:57)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.app.Activity.performCreate(Activity.java:5231)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
07-07 23:28:53.517: E/AndroidRuntime(7735): ... 11 more
07-07 23:28:53.517: E/AndroidRuntime(7735): Caused by: java.lang.reflect.InvocationTargetException
07-07 23:28:53.517: E/AndroidRuntime(7735): at java.lang.reflect.Constructor.constructNative(Native Method)
07-07 23:28:53.517: E/AndroidRuntime(7735): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
07-07 23:28:53.517: E/AndroidRuntime(7735): ... 24 more
07-07 23:28:53.517: E/AndroidRuntime(7735): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0b0039 a=-1 r=0x7f0b0039}
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.content.res.Resources.loadDrawable(Resources.java:2068)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.view.View.<init>(View.java:3589)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.widget.TextView.<init>(TextView.java:623)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.widget.Button.<init>(Button.java:107)
07-07 23:28:53.517: E/AndroidRuntime(7735): at android.widget.Button.<init>(Button.java:103)
07-07 23:28:53.517: E/AndroidRuntime(7735): ... 27 more
我一直在苦苦挣扎数小时,但无法确定哪里出了问题以及在哪里。