xmlで次のコードを使用して、間に仕切りがある2つのラジオボタンを生成しています。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:paddingLeft="60dp"
android:text="Male" />
<View
android:id="@+id/firstDivider"
android:layout_width="2dp"
android:layout_height="match_parent"
android:layout_marginLeft="40dp"
android:background="#939393" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:paddingLeft="60dp"
android:text="Female" />
</LinearLayout>
これは正常に機能し、ViewPager内(タブの1つ)で使用されています。
興味深いことに、ViewPager内を十分に前後にスクロールすると、ボタンの1つのテキストが女性に変わります。したがって、最終的に、2つの女性のラジオボタンを取得します。
これはViewRecyclingと関係があるように見えますが、2つの明確にハードコードされたボタン(たとえば、ListViewアイテムではない)であるため、なぜ発生するのかわかりません。
もちろん、button.setText(...)
Javaを追加することはできますが(うまくいけば修正されるでしょう)、これに気付いたばかりで、説明がありませんでした。
編集:予想どおり、強制終了してアプリケーションを再起動すると、通常の状態に戻ります。2つのFemale
ボタンを取得するには、手順を繰り返す必要があります。別のアクティビティ/etc/ etcに切り替えても、2つの「女性」ボタンのままになります。