gpt4 book ai didi

Android:不幸的是(项目名称)已停止工作

转载 作者:太空狗 更新时间:2023-10-29 15:53:47 26 4
gpt4 key购买 nike

• 将提出预定义问题的区域• 将问题留在屏幕上时会显示问题答案的按钮• 显示答案的区域• 一个按钮,可以转换到格式与本屏幕相同的屏幕,并显示下一个问题• 将导致应用程序结束的按钮(过渡到 (3))

我正在尝试完成并且在运行程序时出现错误的情况,我将提供 logcat。我是 android 编程的新手,所以这可能是某个地方的愚蠢错误。

唯一应该起作用的是通过按下按钮从 1 个问题更改为下一个问题,仅此而已。只完成了 2/5。

    10-30 14:20:27.646: D/AndroidRuntime(769): Shutting down VM
10-30 14:20:27.646: W/dalvikvm(769): threadid=1: thread exiting with uncaught exception (group=0x41465700)
10-30 14:20:27.706: E/AndroidRuntime(769): FATAL EXCEPTION: main
10-30 14:20:27.706: E/AndroidRuntime(769): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidassignment2/com.example.androidassignment2.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class Textview
10-30 14:20:27.706: E/AndroidRuntime(769): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.os.Handler.dispatchMessage(Handler.java:99)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.os.Looper.loop(Looper.java:137)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.app.ActivityThread.main(ActivityThread.java:5103)
10-30 14:20:27.706: E/AndroidRuntime(769): at java.lang.reflect.Method.invokeNative(Native Method)
10-30 14:20:27.706: E/AndroidRuntime(769): at java.lang.reflect.Method.invoke(Method.java:525)
10-30 14:20:27.706: E/AndroidRuntime(769): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-30 14:20:27.706: E/AndroidRuntime(769): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-30 14:20:27.706: E/AndroidRuntime(769): at dalvik.system.NativeStart.main(Native Method)
10-30 14:20:27.706: E/AndroidRuntime(769): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class Textview
10-30 14:20:27.706: E/AndroidRuntime(769): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
10-30 14:20:27.706: E/AndroidRuntime(769): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.app.Activity.setContentView(Activity.java:1895)
10-30 14:20:27.706: E/AndroidRuntime(769): at com.example.androidassignment2.MainActivity.onCreate(MainActivity.java:23)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.app.Activity.performCreate(Activity.java:5133)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
10-30 14:20:27.706: E/AndroidRuntime(769): ... 11 more
10-30 14:20:27.706: E/AndroidRuntime(769): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.Textview" on path: DexPathList[[zip file "/data/app/com.example.androidassignment2-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.androidassignment2-1, /system/lib]]
10-30 14:20:27.706: E/AndroidRuntime(769): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
10-30 14:20:27.706: E/AndroidRuntime(769): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-30 14:20:27.706: E/AndroidRuntime(769): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.view.LayoutInflater.createView(LayoutInflater.java:559)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:652)
10-30 14:20:27.706: E/AndroidRuntime(769): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
10-30 14:20:27.706: E/AndroidRuntime(769): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
10-30 14:20:27.706: E/AndroidRuntime(769): ... 21 more
10-30 14:20:32.196: I/Process(769): Sending signal. PID: 769 SIG: 9

屏幕 1

package com.example.androidassignment2;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.content.Intent;




public class MainActivity extends Activity {






@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


Button next = (Button) findViewById(R.id.QButton);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), AndroidAssignment2_1.class);
startActivityForResult(myIntent, 0);
}
});

}



@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}



}

屏幕 2

package com.example.androidassignment2;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.content.Intent;

public class AndroidAssignment2_1 extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_android_assignment2_1);

Button next = (Button) findViewById(R.id.QButton);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
});

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.android_assignment2_1, menu);
return true;
}

}

1 和 2 的 xml 大部分相同。

<LinearLayout 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:orientation="vertical" >

<Textview android:id="@+id/Questions"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:text="@string/Q1" />

<Button android:id="@+id/QButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_question" />

<Button android:id="@+id/AButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />

<Textview android:id="@+id/Answers"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:hint="@string/A1" />

<Button android:id="@+id/QuitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_quit" />


</LinearLayout>



<LinearLayout 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:orientation="vertical" >

<Textview android:id="@+id/Questions"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:text="@string/Q2" />

<Button android:id="@+id/QButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_question" />

<Button android:id="@+id/AButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />

<Textview android:id="@+id/Answers"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:hint="@string/A2" />

<Button android:id="@+id/QuitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_quit" />


</LinearLayout>

最佳答案

改变

<Textview android:id="@+id/Questions"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:text="@string/Q1" />

 <TextView android:id="@+id/Questions"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:text="@string/Q1" />

注意TextView的拼写

下一行的最后一部分说它不能膨胀一个类 Textview 我们知道原因是因为那不是类的实际拼写

10-30 14:20:27.706: E/AndroidRuntime(769): java.lang.RuntimeException: 
Unable to start activity ComponentInfo
{com.example.androidassignment2/com.example.androidassignment2.MainActivity}:
android.view.InflateException:
Binary XML file line #7: Error inflating class Textview / this part here

将所有 TextView 更改为正确的拼写。

关于Android:不幸的是(项目名称)已停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19691800/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com