gpt4 book ai didi

java.lang.IllegalStateException : Could not execute method for android:onClick. 应用程序崩溃

转载 作者:行者123 更新时间:2023-12-04 07:54:57 25 4
gpt4 key购买 nike

我想创建一个简单的测验应用程序,有 4 个答案。它确实有效,但一段时间后应用程序崩溃。崩溃发生在不同的时间:有时当我回答超过 10 个问题时,有时直到第 10 个问题,有时在第一个问题中。我花了很多时间在 google、youtube、stackoverflow 上寻找答案。但找不到我的案例
XML:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SavolJavob"
android:gravity="center_vertical"
android:background="@color/black">
<TextView
android:id="@+id/questionTextView"
android:layout_width="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_height="wrap_content"
android:layout_marginBottom="250dp"
android:layout_gravity="center_vertical"
android:text="Payg'ambarimiz Muhammad(s.a.v) qaysi shaharda tavallud topganlar?"
android:textColor="@color/white"
android:textSize="24sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="200dp"
android:id="@+id/option1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/black"
android:text="Makkada"
android:paddingRight="25dp"
android:paddingLeft="25dp"
android:onClick="nextQuestion"/>
<Button
android:id="@+id/option2"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/black"
android:text="Madinada"/>
<Button
android:id="@+id/option3"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/black"
android:text="Rimda"/>
<Button
android:id="@+id/option4"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="@color/black"
android:text="To'gri javob yo'q"/>
</LinearLayout>
</LinearLayout>
SavolJavob 类
    package com.example.islomniorganamiz;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Random;
public class SavolJavob extends AppCompatActivity {
Random random=new Random();
int questionNumber=0;
TextView questionTextView;
Button option1,option2,option3,option4;
Questions questions=new Questions();
int random_number;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_savol_javob);

questionTextView=findViewById(R.id.questionTextView);
option1=findViewById(R.id.option1);
option2=findViewById(R.id.option2);
option3=findViewById(R.id.option3);
option4=findViewById(R.id.option4);
nextQuestion();
}

public void nextQuestion(){
random_number=random.nextInt(11);
questionTextView.setText(questions.questionsArray[random_number]);
option1.setText(questions.optionsArray[random_number][0]);
option2.setText(questions.optionsArray[random_number][1]);
option3.setText(questions.optionsArray[random_number][2]);
option4.setText(questions.optionsArray[random_number][3]);
questionNumber++;
}

public void nextQuestion(View view) {
random_number=random.nextInt(11);
questionTextView.setText(questions.questionsArray[random_number]);
option1.setText(questions.optionsArray[random_number][0]);
option2.setText(questions.optionsArray[random_number][1]);
option3.setText(questions.optionsArray[random_number][2]);
option4.setText(questions.optionsArray[random_number][3]);
questionNumber++;
}
}
问题类:
    package com.example.islomniorganamiz;

public class Questions {
public String [] questionsArray={
"1chi savol",
"Payg'ambarimiz Muhammad(s.a.v) qaysi shaharda tavallud topganlar",
"3chi savol",
"4chi savol",
"5chi savol",
"6chi savol",
"7chi savol",
"8chi savol",
"9chi savol",
"10chi savol"
};
public String[][] optionsArray={
{"1.1","1.2","1.3","1.4"},
{"2.1","2.2","2.3","2.4"},
{"3.1","3.2","3.3","3.4"},
{"4.1","4.2","4.3","4.4"},
{"5.1","5.2","5.3","5.4"},
{"6.1","6.2","6.3","6.4"},
{"7.1","7.2","7.3","7.4"},
{"8.1","8.2","8.3","8.4"},
{"9.1","9.2","9.3","9.4"},
{"10.1","10.2","10.3","10.4"}


};
}
错误:
03/22 21:52:27: Launching 'app' on Physical Device.
App restart successful without requiring a re-install.
$ adb shell am start -n "com.example.islomniorganamiz/com.example.islomniorganamiz.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 15140 on device 'samsung-sm_a510f-3300997dc3f13377'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
W/System: ClassLoader referenced unknown path: /data/app/com.example.islomniorganamiz-2/lib/arm
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2463)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:938)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:806)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:693)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:170)
at void com.example.islomniorganamiz.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:26)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6955)
at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1126)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2927)
at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:3045)
at void android.app.ActivityThread.-wrap14(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1642)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
at void android.os.Looper.loop() (Looper.java:154)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6776)
at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:1496)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:1386)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.islomniorganamiz-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.islomniorganamiz-2/lib/arm, /system/lib, /vendor/lib]]
at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2463)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:938)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:806)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:693)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:170)
at void com.example.islomniorganamiz.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:26)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6955)
at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1126)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2927)
at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:3045)
at void android.app.ActivityThread.-wrap14(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1642)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
at void android.os.Looper.loop() (Looper.java:154)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6776)
at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:1496)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:1386)
D/TextView: setTypeface with style : 0
D/Choreographer: init sf_choreo_doframe debug_Level : 0x4f4cdebug_game_running : false
D/ViewRootImpl@aadc270[MainActivity]: ThreadedRenderer.create() translucent=false
D/InputTransport: Input channel constructed: fd=57
D/ViewRootImpl@aadc270[MainActivity]: setView = DecorView@fda19e9[MainActivity] touchMode=true
D/ViewRootImpl@aadc270[MainActivity]: dispatchAttachedToWindow
D/ViewRootImpl@aadc270[MainActivity]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][1080,1920] result=0x27 surface={isValid=true -547665920} surfaceGenerationChanged=true
D/ViewRootImpl@aadc270[MainActivity]: mHardwareRenderer.initialize() mSurface={isValid=true -547665920} hwInitialized=true
D/libEGL: loaded /vendor/lib/egl/libGLES_mali.so
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1080x1920]-format:1
D/ViewRootImpl@aadc270[MainActivity]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
MSG_WINDOW_FOCUS_CHANGED 1
mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -547665920}
V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@4936f88 nm : com.example.islomniorganamiz ic=null
I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport: Input channel constructed: fd=69
W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@14dcfd2 nm : com.example.islomniorganamiz ic=null
D/ViewRootImpl@aadc270[MainActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=true -547665920} surfaceGenerationChanged=false
D/ViewRootImpl@aadc270[MainActivity]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
D/ViewRootImpl@aadc270[MainActivity]: ViewPostImeInputStage processPointer 0
W/System: ClassLoader referenced unknown path: /system/framework/QPerformance.jar
E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
V/BoostFramework: BoostFramework() : mPerf = null
D/ViewRootImpl@aadc270[MainActivity]: ViewPostImeInputStage processPointer 1
D/ViewRootImpl@aadc270[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/ViewRootImpl@4318b24[Menu]: ThreadedRenderer.create() translucent=false
D/InputTransport: Input channel constructed: fd=67
D/ViewRootImpl@4318b24[Menu]: setView = DecorView@355668d[Menu] touchMode=true
D/ViewRootImpl@4318b24[Menu]: dispatchAttachedToWindow
D/ViewRootImpl@4318b24[Menu]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][1080,1920] result=0x27 surface={isValid=true -323749888} surfaceGenerationChanged=true
D/ViewRootImpl@4318b24[Menu]: mHardwareRenderer.initialize() mSurface={isValid=true -323749888} hwInitialized=true
D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1080x1920]-format:1
D/ViewRootImpl@4318b24[Menu]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 63 - 0, 0) vi=Rect(0, 63 - 0, 0) or=1
MSG_WINDOW_FOCUS_CHANGED 1
mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -323749888}
V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@ea9d042 nm : com.example.islomniorganamiz ic=null
I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport: Input channel constructed: fd=73
Input channel destroyed: fd=69
D/ViewRootImpl@aadc270[MainActivity]: mHardwareRenderer.destroy()#1
D/ViewRootImpl@aadc270[MainActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true
D/ViewRootImpl@aadc270[MainActivity]: mHardwareRenderer.destroy()#4
dispatchDetachedFromWindow
D/InputTransport: Input channel destroyed: fd=57
D/ViewRootImpl@4318b24[Menu]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@4318b24[Menu]: ViewPostImeInputStage processPointer 1
D/ViewRootImpl@4318b24[Menu]: MSG_WINDOW_FOCUS_CHANGED 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/ViewRootImpl@7b042d6[SavolJavob]: ThreadedRenderer.create() translucent=false
D/InputTransport: Input channel constructed: fd=69
D/ViewRootImpl@7b042d6[SavolJavob]: setView = DecorView@1edd957[SavolJavob] touchMode=true
D/ViewRootImpl@7b042d6[SavolJavob]: dispatchAttachedToWindow
D/ViewRootImpl@7b042d6[SavolJavob]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][1080,1920] result=0x27 surface={isValid=true -323119104} surfaceGenerationChanged=true
D/ViewRootImpl@7b042d6[SavolJavob]: mHardwareRenderer.initialize() mSurface={isValid=true -323119104} hwInitialized=true
D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1080x1920]-format:1
D/ViewRootImpl@7b042d6[SavolJavob]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 63 - 0, 0) vi=Rect(0, 63 - 0, 0) or=1
MSG_WINDOW_FOCUS_CHANGED 1
mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -323119104}
V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@ac83c44 nm : com.example.islomniorganamiz ic=null
I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport: Input channel constructed: fd=78
Input channel destroyed: fd=73
D/OpenGLRenderer: endAllActiveAnimators on 0xecb48700 (RippleDrawable) with handle 0xe383e450
D/ViewRootImpl@4318b24[Menu]: mHardwareRenderer.destroy()#1
D/ViewRootImpl@4318b24[Menu]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 1
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 1
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 1
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 1
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 1
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 1
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 1
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 1
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 0
D/ViewRootImpl@7b042d6[SavolJavob]: ViewPostImeInputStage processPointer 1
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.islomniorganamiz, PID: 15140
java.lang.IllegalStateException: Could not execute method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:414)
at android.view.View.performClick(View.java:6261)
at android.widget.TextView.performClick(TextView.java:11163)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
at android.view.View$PerformClick.run(View.java:23748)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409)
at android.view.View.performClick(View.java:6261) 
at android.widget.TextView.performClick(TextView.java:11163) 
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119) 
at android.view.View$PerformClick.run(View.java:23748) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6776) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) 
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=10; index=10
at com.example.islomniorganamiz.SavolJavob.nextQuestion(SavolJavob.java:44)
at java.lang.reflect.Method.invoke(Native Method) 
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409) 
at android.view.View.performClick(View.java:6261) 
at android.widget.TextView.performClick(TextView.java:11163) 
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119) 
at android.view.View$PerformClick.run(View.java:23748) 
at android.os.Handler.handleCallback(Handler.java:751) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6776) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) 

最佳答案

Caused by: java.lang.ArrayIndexOutOfBoundsException: length=10; index=10


10 元素数组中的索引从 0 到 9。您试图访问索引 10 处不存在的元素。
简单的解决方法是使用 nextInt(11) 更改随机索引至 nextInt(10) .为了更好的 future 证明,您也可以制作 nextInt(questionsArray.length) .

关于java.lang.IllegalStateException : Could not execute method for android:onClick. 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66753920/

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