gpt4 book ai didi

java - 安卓java.lang.RuntimeException : Unable to resume activity

转载 作者:行者123 更新时间:2023-11-29 03:45:56 25 4
gpt4 key购买 nike

Caused by: java.lang.NullPointerException
at com.myapp.code.WordDescription.onRestart(WordDescription.java:685)
at android.app.Instrumentation.callActivityOnRestart(Instrumentation.java:1245)
at android.app.Activity.performRestart(Activity.java:3892)
at android.app.Activity.performResume(Activity.java:3911)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2424)

我真的不明白为什么我总是在 WordDescription.onRestart 上出错。许多人提示强制关闭问题。关于如何解决这个问题的任何线索?谢谢

我认为这个是相关的..

public class MyArrayAdapter extends ArrayAdapter<String> {

private final Activity context;
private final String[] aListText;
private final String [] meaningText;

public MyArrayAdapter(Activity context, String[] wordText, String[] meaningText) {
super(context, R.layout.desclist2, wordText);
this.context=context;
this.aListText= wordText;
this.meaningText=meaningText;
}
} // .....

@Override
public void onRestart(){
super.onRestart();
clickFlag = false;
clickWordFlag = false;
myArrayAdapter.notifyDataSetChanged(); <-- line 685
}
Handler handler = new Handler(){ <-- line 709
@Override
public void handleMessage(Message msg){
progressDialog.dismiss();

if{ ....
}else{
myArrayAdapter = new MyArrayAdapter(WordDescription.this, wordArray, meaningArray);
listView.setAdapter(myArrayAdapter);
}

}

最佳答案

改变

myArrayAdapter.notifyDataSetChanged();

if(myArrayAdapter != null)
myArrayAdapter.notifyDataSetChanged();

我强烈建议您按照 Vipul Shah 在他的评论中所说的去做。

关于java - 安卓java.lang.RuntimeException : Unable to resume activity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10897551/

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