簡體   English   中英

我不參加下一個活動嗎?

[英]I don't go next Activity?

我在這個項目中遇到了太多問題,我沒有打算使用這些數據,完成后將轉到HomeActivity而不是DoneActivity

詳細活動:

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();

DoneActivity:

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));

如何處理這些數據?

這是錯誤:

在此處輸入圖片說明

確保您正在初始化兩個文本視圖

TextView txt_score = findViewById( R.id。id_of_txt_score );

TextView txt_get_question = findViewById( R.id。id_of_txt_get_question );

 txt_score.setText(String.format("SCORE : %d",score));
 txt_get_question.setText(String.format("PASSED : %d / %d",correctAnswer,totalQuestion));

因為您在第56行獲得了空指針異常。

表示您未正確初始化視圖。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM