1
我完全不熟悉Android,並在做家庭作業。我正在使用Android Studio 0.8.11。我試過搜索,但沒有找到合適的答案。無法啓動活動 - 二進制XML文件行,錯誤膨脹類
我會很感激任何幫助與破譯錯誤信息:
package com.mken.csd_homework5;
import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.text.Layout;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import org.w3c.dom.Text;
public class random_circles_activity extends Activity {
com.mken.csd_homework5.DrawView dv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_random_circles_activity);
}
}
DrawCircle.java
package com.mken.csd_homework5;
import android.view.View;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
public class DrawCircle extends View
{
public DrawCircle(Context con)
{
super(con);
}
}
activity_random_circles_activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".random_circles_activity">
<com.mken.csd_homework5.DrawCircle
android:id="@+id/dcCustom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2"
android:layout_alignBottom="@+id/button"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
錯誤的logcat:
10-01 02:11:35.120: E/AndroidRuntime(2910): Process: com.mken.csd_homework5, PID: 2910
10-01 02:11:35.120: E/AndroidRuntime(2910): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mken.csd_homework5/com.mken.csd_homework5.random_circles_activity}: android.view.InflateException: Binary XML file line #18: Error inflating class com.mken.csd_homework5.DrawCircle
10-01 02:11:35.120: E/AndroidRuntime(2910): Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class com.mken.csd_homework5.DrawCircle
10-01 02:11:35.120: E/AndroidRuntime(2910): at com.mken.csd_homework5.random_circles_activity.onCreate(random_circles_activity.java:22)
就是這樣!謝謝您的幫助! – kent510 2014-10-01 07:09:38