2014-07-20 50 views
0

我的任務是有5個問題,每個問題包含5個選項按鈕(Answers)。當我按下一個選項(按鈕)時,該值應該存儲在一個數組中問題option.when我按下一個按鈕相同的過程正在發生,直到5個question.i要存儲的問題和相應的答案每個陣列如何存儲每個按鈕點擊一個數組-Android

公共無效的onClick(視圖v){

case R.id.btnForword: 

登入]。我(「計數值」,「」+計數);

 if (count < str_Q_QuestionArray.length - 1) { 


      count = count + 1; 

      tvQuestion.setText("" + (count + 1) + ". " 
        + str_Q_QuestionArray[count]); 


      btnOpt_1.setText(str_Opt1[count]); 

      btnOpt_2.setText(str_Opt2[count]); 

      btnOpt_3.setText(str_Opt3[count]); 

      btnOpt_4.setText(str_Opt4[count]); 
      btnOpt_5.setText(str_Opt5[count]); 

      Log.i("Count Value", "" + count); 

     } else { 
      Intent intFeedEmail = new Intent(Feedback.this, 

        FeedBack_Email.class); 

      startActivity(intFeedEmail); 
     } 

     break; 

    case R.id.btnPrevious: 

Log.i(「Count Value」,「」+ count);

 String countTxt = "" + count; 


     if (count == 0) { 


      Log.i("Nothing to do ", "" + count); 

     } else { 

      count = count - 1; 

      tvQuestion.setText(countTxt + ". " + str_Q_QuestionArray[count]); 

      btnOpt_1.setText(str_Opt1[count]); 


      btnOpt_2.setText(str_Opt2[count]); 


      btnOpt_3.setText(str_Opt3[count]); 


      btnOpt_4.setText(str_Opt4[count]); 


      btnOpt_5.setText(str_Opt5[count]); 

      Log.i("Count Value ::::", "" + count); 

     } 

     break; 

情況下R.id.opn1:

 btnOpt_1.setBackgroundResource(R.drawable.btn_toggle_blue); 


    btnOpt_1.setEnabled(false); 


    String excellent=btnOpt_1.getText().toString(); 

    break; 

。 。 。 情況下R.id.opn5:

 btnOpt_5.setBackgroundResource(R.drawable.btn_toggle_blue); 




    btnOpt_5.setEnabled(false); 



    String bad=btnOpt_2.getText().toString(); 



    break; 

回答

0

我沒有完全理解這個問題,但也許這將是有意義

創建,保持在2個變量 例如類名QA問答的一類。 從類中創建數組

QA[] = new QA[5]; 

這將是basicly給你節省將q &的位置 當你完成測驗你可以在數組循環,並顯示第q &一個

我關門了嗎?

希望它有幫助。