私はいくつかの質問をし、多くの答えを保存する質問と回答のダイアログを設定しようとしています。 QuestionsAnswer.java
にintを渡すと、@string/questions[i]
と@string/answers[i]
が設定されます。私はここで検索することで自分の答えを見つけようとしました。単一のjava switch文が2つの変数を返す
擬似コード:
public class QuestionAnswer {
public static void QuestionAnswer(int QuestionNum) {
String question;
String answer;
switch (QuestionNum) {
case 1: question = "What are you doing?", answer = "activity";
break;
case 2: question = "Where have you been?", answer = "Location";
break;
case 3: question = "Are you looking at me?", answer = "Boolean";
break;
case 4: question = "What do you think about when I'm not around?", answer = "Crazy";
break;
case 5: question = "Do you want to play a game?", answer = "MovieQuote";
break;
case 6: question = "Does a cat have nine lives?", answer = "CanCatsFly";
break;
}
//question is a string variable that will change the question text for the dialog
R.string.Questions = question;
//answer is a string variable that will change what column name the answer will be stored into
R.string.answers = answer;
}
}
ここでは、編集後の完成版です。それは完全に動作します! パブリッククラスQuestionAnswer {
public static void QuestionAnswer(int QuestionNum) {
String question;
String answer;
switch (QuestionNum) {
case 1: question = "What are you doing?";
answer = "activity";
break;
case 2: question = "Where have you been?";
answer = "Location";
break;
case 3: question = "Are you looking at me?";
answer = "Boolean";
break;
case 4: question = "What do you think about when I'm not around?";
answer = "Crazy";
break;
case 5: question = "Do you want to play a game?";
answer = "MovieQuote";
break;
case 6: question = "Does a cat have nine lives?";
answer = "CanCatsFly";
break;
}
//question is a string variable that will change the question text for the dialog
R.string.Questions = question;
//answer is a string variable that will change what column name the answer will be stored into
R.string.answers = answer;
}
}
を使用することができます... –
それをすべて投げ捨て、ある種のテーブルを使用してください。 – EJP
私は構文エラーを嫌いです。笑...しかし、今は素晴らしいです!ありがとう! –