0
我已經創建了一個android應用程序,它從一個活動獲取一些輸入並將其輸出到下一個活動中。該應用在嘗試進行下一個活動時崩潰。問題在於XML,但我無法弄清楚在哪裏。無法啓動活動android.view.InflateException:二進制XML行〜1
最後活動:
package com.example.competitionapp;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class ConfirmationActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_third);
Bundle extras = getIntent().getExtras();
TextView textViewName = (TextView)findViewById(R.id.textViewLabelName);
TextView textViewSurname = (TextView)findViewById(R.id.textViewLabelSurname);
if(extras !=null) {
String nameValue = extras.getString("name");
String surnameValue = extras.getString("surname");
textViewName.setText(nameValue);
textViewSurname.setText(surnameValue);
}
}
}
這是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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="@drawable/bg2"
>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="55dp"
android:text="@string/thanks"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="86dp"
android:text="@string/gl"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textViewLabelName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="TextView" />
<TextView
android:id="@+id/textViewLabelSurname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textViewLabelName"
android:layout_below="@+id/textViewLabelName"
android:layout_marginTop="17dp"
android:text="TextView" />
</RelativeLayout>
和我的日誌貓:
10-24 08:50:01.823: E/AndroidRuntime(840): FATAL EXCEPTION: main
10-24 08:50:01.823: E/AndroidRuntime(840): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.competitionapp/com.example.competitionapp.ConfirmationActivity}:
android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
這是我的第一份工作。我希望這是可以理解的 –
我會先嚐試清理你的項目。 「Project - > Clean ...」 – codeMagic
我清理了項目併發生了相同的錯誤。 –