gpt4 book ai didi

java - 如何将多个字符串传递给另一个 Activity ?

转载 作者:行者123 更新时间:2023-11-29 07:35:53 25 4
gpt4 key购买 nike

<分区>

我正在尝试制作一个测验 Android 应用程序。我正在尝试显示用户在另一项 Activity 中出错的问题和多项选择。我不知道如何转移多个错题。

这是我的测验 java 类。

public class QuizActivityMarketing extends Activity{
private Iterator<Question> questionIterator;
private TextView txtQuestion;
private RadioButton rda, rdb, rdc, rdd;
public Button butNext;
private int qid = 0;
private Question currentQ;
private int score = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);

// Define your views
txtQuestion = (TextView) findViewById(R.id.textView1);
rda = (RadioButton) findViewById(R.id.radio0);
rdb = (RadioButton) findViewById(R.id.radio1);
rdc = (RadioButton) findViewById(R.id.radio2);
rdd = (RadioButton) findViewById(R.id.radio3);
butNext = (Button) findViewById(R.id.button1);



//Log question and option if wrong
TextView question = (TextView) findViewById(R.id.textView1);
RadioButton optA = (RadioButton) findViewById(R.id.radio0);
RadioButton optB = (RadioButton) findViewById(R.id.radio1);
RadioButton optC = (RadioButton) findViewById(R.id.radio2);
RadioButton optD = (RadioButton) findViewById(R.id.radio3);
if (!currentQ.getANSWER().trim().equals(answer.getText())) {
Log.d("Current Question", ""+question.getText());
Log.d("OptionA", ""+optA.getText());
Log.d("OptionB", ""+optB.getText());
Log.d("OptionC", "" + optC.getText());
Log.d("OptionD", "" + optD.getText());
}

// Load the next question, if there are any
if (questionIterator.hasNext()) {
currentQ = questionIterator.next();
setQuestionView(currentQ);
qid++;
}
// Done asking questions
Intent intent1 = getIntent();
int buttonValue = Integer.valueOf(intent1.getExtras().getString("button"));
if (qid > buttonValue)
{

这是我的结果类

public class ResultActivityMarketing extends AppCompatActivity {

//get text view for score
TextView testResult = (TextView) findViewById(R.id.testResult);
//get score
Bundle extras = getIntent().getExtras();
if (extras != null) {
int score = extras.getInt("score");
int numberquestions = extras.getInt("button");
testResult.setText("You got " + score + " out of " + numberquestions + " questions correct");
}
}

}

这是我的结果 Activity 的 XML 类。

    <ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView" >

<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
android:id="@+id/wrong_questions_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Wrong Questions"
android:paddingTop="10dp"/>
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.04" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:layout_marginTop="30dp"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton"/>
</RadioGroup>
</FrameLayout>
</ScrollView>
</LinearLayout>

谁能帮帮我。我真的很感激。我不知道该怎么做。提前致谢!

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