こんにちは、私は Android 用のアプリを作成しようとしています。それを開発するには、さまざまなページや質問をナビゲートする必要があります。このタスクのために、いくつかのラジオボタンを含むラジオグループを定義しました。ただし、これらのラジオボタンは、ユーザーが次または前の質問に移動しても同じままです (テキストのみが変更され、選択された回答は変更されず、常にすべての質問に対して選択されます)。そのため、次の質問に行くときに新しい RadioButtons を作成する必要があると思いますが、前の質問に行くと状態を保存します。
XMLを手伝ってくれるなら、これが私のコードの一部です:
<RadioGroup
android:id="@+id/respuestas3RG"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_below="@id/imagenenunciado3"
android:orientation="vertical">
<RadioButton
android:id="@+id/respuesta3A"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A. RespuestaA"/>
<RadioButton
android:id="@+id/respuesta3B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B. RespuestaB"/>
<RadioButton
android:id="@+id/respuesta3C"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C. RespuestaC"/>
<RadioButton
android:id="@+id/respuesta3D"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="D. RespuestaD"/>
</RadioGroup>
ジャワ:
bNext.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
posicion = posicion +1;
questions.Next();
currentQuestion();
}
最初にすべての radioButtons を作成するか、ユーザーが次の質問に進むときにそれらを生成するのが最適なオプションかどうかはわかりません。ありがとうございました