私のアプリでRadioGroupを使う必要があります。しかし、私は活動中にそれを初期化することはできません。ここでの問題は何ですか?RadioGroupを初期化するには
my screen for example
screen 2
私のアプリでRadioGroupを使う必要があります。しかし、私は活動中にそれを初期化することはできません。ここでの問題は何ですか?RadioGroupを初期化するには
my screen for example
screen 2
こんにちはあなたはこのような何かをしようとしなかった、
RadioGroup mRadioGroup = (RadioGroup) view.findViewById(R.id.amountcollecte_radiogroup);
mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
int id = mRadioGroup.getCheckedRadioButtonId();
View radioButton = mRadioGroup.findViewById(id);
if (radioButton.getId() == R.id.amountcollected_yes_radioButton) {
} else if (radioButton.getId() == R.id.amountcollected_no_radioButton) {
}
}
});
<RadioButton
android:id="@+id/amountcollected_yes_radioButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="@color/black"
android:checked="true"
android:gravity="center"
android:text="Yes"
android:textColor="@color/black"
android:textSize="@dimen/text_large" />
<RadioButton
android:id="@+id/amountcollected_no_radioButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="@color/black"
android:gravity="center"
android:text="No"
android:textColor="@color/black"
android:textSize="@dimen/text_large" />
</RadioGroup>
が、これはあなたを助けることを願っています。
画像の代わりに試したコードを追加することができます –
@NeelaySrivastava、なぜですか?)画像に2行あります) – JokeRaes