一連の多肢選択問題を練習するトレーニング アプリケーションを実行しています。2 つの質問の間でスライド アニメーションを実行したいと思います。ユーザーが 1 つの質問に正しく答えると、左にスライドし、新しい質問が右からスライドします。
現在、私の質問/回答のレイアウトは次のようになっています (question.xml):
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center"
>
<TextView
android:id="@+id/question"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="8pt"
android:textStyle="bold"
android:layout_margin="5px"
android:layout_marginBottom="10dp"
android:clickable="true"
/>
<RadioGroup android:id="@+id/answers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="5px"
>
<RadioButton android:id="@+id/answer_a"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="7pt"
android:layout_margin="5dp"
android:layout_marginBottom="10dp"
/>
<RadioButton android:id="@+id/answer_b"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="7pt"
android:layout_margin="5dp"
android:layout_marginBottom="10dp"
/>
<RadioButton android:id="@+id/answer_c"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="7pt"
android:layout_margin="5dp"
android:layout_marginBottom="10dp"
/>
</RadioGroup>
</LinearLayout>
</ScrollView>
質問に回答し、回答を評価した後、質問のテキストと 3 つの回答を変更しました。かなり簡単です。
ここで、ViewFlipper を使用してアニメーションを実行してみました。
<ViewFlipper android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<include android:id="@+id/current_view" layout="@layout/question" />
<include android:id="@+id/next_view" layout="@layout/question" />
</ViewFlipper>
しかし、その方法では、現在の質問と次の質問のビューに個別にアクセスできませんfindViewById
。
これを行うには、ID が異なるだけで 2 つの同じ質問レイアウトが必要ですか? 私には冗長に思えます。または、2 番目のビューで質問と回答のみにアクセスする別の方法はありますか?
または、これを達成するためのより簡単な方法はありますか?
ありがとう!