リストビュー (2 つのテキストビューと 1 つのラジオ ボタン) に問題があります。
問題: 私の考えでは、ユーザーがリストビュー内の項目をクリックすると、ラジオ ボタンが自動的にチェックされます。
しばらく探していましたが、ラジオボタンが機能しません。
私のXML
<RadioButton
android:id="@+id/rdBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false" />
私のアダプター
r = (RadioButton) convertView.findViewById(R.id.rdBtn);
r.setChecked(selectedPosition == position);
r.setTag(position);
r.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//r.setChecked(true);
Toast.makeText(context, InformationActivity.result,
Toast.LENGTH_SHORT).show();
selectedPosition = (Integer) view.getTag();
notifyDataSetInvalidated();
}
});
return convertView;
私は試した
r.setChecked(true);
私のアクティビティクラス内で最初のクリックは機能しましたが、2番目はリストビューで別のアイテムを選択しました.
あなたの何人かが私を助けてくれることを願っています。ありがとう