0

我的应用程序有问题,我发布了错误的 logcat、文件 mainactivity 的 XML 代码以及 MainActivity 类的 Java 代码:

    E/AndroidRuntime(16123):FATAL EXCEPTION: main
    E/AndroidRuntime(16123):java.lang.RuntimeException: Unable to start activity ComponentInfo{it.bisemanuDEV.mathTools/it.bisemanuDEV.mathTools.MainActivity}: android.view.InflateException: Binary XML file line #58: Error inflating class <unknown>
    E/AndroidRuntime(16123):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
E/AndroidRuntime(16123):at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2098)
E/AndroidRuntime(16123):at android.app.ActivityThread.access$600(ActivityThread.java:138)
E/AndroidRuntime(16123):at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204)

这是 MainActivity 代码:

public class MainActivity extends Activity {
Intent intent, intent1, intent2,intent3,intent4;
Button Button1, button2, Button3,Button4,Button5;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainactivity);

    intent = new Intent(this, Calculator.class);
    intent1 = new Intent(this, prima.class);
    intent2 = new Intent(this, primaEQ.class);
    intent3 = new Intent(this, conversion.class);
    intent4 = new Intent(this, ActivityMain.class);

    Button1 = (Button) findViewById(R.id.button1);
    button2 = (Button) findViewById(R.id.button2);
    Button3 = (Button) findViewById(R.id.button3);
    Button4 = (Button) findViewById(R.id.button4);
    Button5 = (Button) findViewById(R.id.button5);

    Button1.setOnClickListener(new OnClickListener(){
        public void onClick(View arg0) {

            finish();
            startActivity(intent);      
    }
});

    Button4.setOnClickListener(new OnClickListener(){
        public void onClick(View arg0) {

            finish();
            startActivity(intent3);     
    }
});
    Button5.setOnClickListener(new OnClickListener(){
        public void onClick(View arg0) {

            finish();
            startActivity(intent4);     
    }
});

    button2.setOnClickListener(new OnClickListener(){
        public void onClick(View arg0) {

            finish();
            startActivity(intent1);     
    }
});

    Button3.setOnClickListener(new OnClickListener(){
        public void onClick(View arg0) {

            finish();
            startActivity(intent2);     
    }
});
}
}

这里是 XML 代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="@drawable/lavagna"
android:gravity="center"
android:orientation="vertical" >
<Button
    android:id="@+id/button1"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_gravity="center"
    android:background="@drawable/but_graph" />
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" >

    <Button
        android:id="@+id/button3"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginRight="8dp"
        android:background="@drawable/but_eq" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="100dp"
        android:layout_height="73dp"
        android:layout_gravity="center"
        android:layout_marginRight="8dp"
        android:background="@drawable/logo" />

    <Button
        android:id="@+id/button2"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/but_matrix" />

</LinearLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="10dp" >

    <Button
        android:id="@+id/button5"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginRight="30dp"
        android:background="@drawable/but_conv" />

    <Button
        android:id="@+id/button4"
        android:layout_width="100dip"
        android:layout_height="100dip"
        android:background="@drawable/but_unit" />

</LinearLayout>

我不明白如何解决问题,希望对您有所帮助。谢谢

4

0 回答 0