- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想创建一个简单的测验应用程序,有 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
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/
我有一个坦克射击弹药的游戏。我对这部分代码的目标是检查它们是否与“碰撞”磁贴发生碰撞,如果是,则将其和磁贴移除。 代码如下所示,每 1/60 秒检查一次: Iterator iterator = sh
我尝试使用 JSR-303 注释(类级别)和验证器实现为 play 2.0.1 编写自定义表单验证器。 不幸的是,当我提交表单并且验证失败时,我收到了一个 IllegalStateException,
根据answer of BalusC ,我用过 FacesContext.getCurrentInstance().getExternalContext().redirect(url); 在我的 @P
这个问题已经有答案了: Copy a stream to avoid "stream has already been operated upon or closed" (10 个回答) 已关闭 5
这个问题已经有答案了: Spring: getOutputStream() has already been called for this response (3 个回答) 已关闭 4 年前。 我正
我正在尝试将 Activity 转换为 FragmentActivty 对象,以便获得 FragmentManager 对象 public class Main extends ListActivit
我正在尝试使用可编辑的组合框,通过用户的某些击键从数据库中快速搜索客户端的功能。我想要的是,用户将输入一些字母,如果这些字母与某些客户端匹配,这些客户端将保留在组合框的当前数据模型中。 代码如下。请修
这个问题已经有答案了: You need to use a Theme.AppCompat theme (or descendant) with this activity. Change to Th
我正在使用 Android Studio 和 Genymotion 作为模拟器创建一个应用程序,其中我在 3 个 EditText 中输入数据,当我单击按钮将其存储在 sqlite 数据库中时,它不起
我正在为 Android 构建一个简单的消息应用程序,并且在发送短信时遇到一些问题。我第一次使用 OnlickListener 时,消息被发送并显示在我的 ListView 中。当我在 Activit
我了解到 collect() 和 forEach() 都是流终端操作,在同一个流上调用它们会抛出 非法状态异常。但是,以下代码可以成功编译并按升序打印每个字符串的长度。不会引发任何异常。怎么会这样?
我对 classcastException 和非法状态异常都有点困惑,因为在大多数情况下它们看起来都很相似。 我在这个java代码中遇到了一个问题 class consumer {
我正在尝试这个小计算器程序。当我调用calculateResult()方法时,我想在第二个操作数为零且运算符为除法时显示IllegalStateException错误。但尽管如此,我在calculat
Stacktrace Here 导入java.util.*; 公共(public)类 AccountClient { public static void main(String[] args) {
我正在使用 readEntity() 方法读取 JAVAX 响应,但我收到以下堆栈跟踪: java.lang.IllegalStateException: Entity input stream ha
我是安卓新手。我正在尝试进行简单的登录 Activity ,但当我单击“登录”按钮时出现运行时错误。我认为我没有正确获取数据。我已经检查过,SQLite 中有一个与该 PK 相对应的数据。 日志猫。
我正在创建一个登录页面,工程师可以通过以“engg”开头的用户名登录。问题出在登录页面,当我使用正确的密码提供正确的输入时,它会给出“非法状态异常”。在错误的输入中,它工作正常。就像当我在我的 ora
我正在使用一些现有的 Java 设备驱动程序软件,该软件使用 JavaCOMM 进行串行 I/O。我昨天看到它抛出一个异常,其中有一个 IllegalStateException - 端口从 publ
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
我正在使用 Adventnet SNMPAPI 开发 UDP 监听程序。现在我需要将监听数据保存到数据库中。当我这样做时,我遇到了错误。任何人都可以帮忙解决这个问题吗... 这是我的代码。 impor
我是一名优秀的程序员,十分优秀!