Android 我不去下一个活动?
在这个项目中,我遇到了太多的问题,我不打算收集这些数据,当它完成后,它将进入家庭活动,而不是DoneActivity 活动详情: DoneActivity: 如何处理这些数据 以下是错误:Android 我不去下一个活动?,android,android-intent,Android,Android Intent,在这个项目中,我遇到了太多的问题,我不打算收集这些数据,当它完成后,它将进入家庭活动,而不是DoneActivity 活动详情: DoneActivity: 如何处理这些数据 以下是错误: 确保您正在初始化两个文本视图 TextView txt_分数=findViewByIdR.id.id_的txt_分数 TextView txt_get_question=findviewbydr.id.id_txt_get_question的_ 因为您在第56行得到空指针异常 表示您的视图未正确初始化。您能在
确保您正在初始化两个文本视图 TextView txt_分数=findViewByIdR.id.id_的txt_分数 TextView txt_get_question=findviewbydr.id.id_txt_get_question的_ 因为您在第56行得到空指针异常
表示您的视图未正确初始化。您能在此处添加logcat错误详细信息吗?如@Sunny所说,请添加您的logcat错误。为什么要使用finish,你到底想做什么?我认为完成是问题所在。似乎你的完成活动中有某种东西导致崩溃,因为堆栈中的下一个可用活动是Home活动,所以它在前面。如果你检查一下日志并把它寄到这里就好了。
Intent intent = new Intent(this,DoneActivity.class);
Bundle dataSend = new Bundle();
dataSend.putInt("SCORE",score);
dataSend.putInt("TOTAL",totalQuestion);
dataSend.putInt("CORRECT",correctAnswer);
intent.putExtras(dataSend);
startActivity(intent);
finish();
Bundle extra = getIntent().getExtras();
if (extra != null){
int score = extra.getInt("SCORE");
int totalQuestion = extra.getInt("TOTAL");
int correctAnswer = extra.getInt("CORRECT");
txt_score.setText(String.format("SCORE : %d",score));
txt_get_question.setText(String.format("PASSED : %d / %d",correctAnswer,totalQuestion));
txt_score.setText(String.format("SCORE : %d",score));
txt_get_question.setText(String.format("PASSED : %d / %d",correctAnswer,totalQuestion));