जोड़ने के बाद काम नहीं करता मैं एक ListView
(my_list.xml) है:ListView onClickListener() RadioButton
<ListView
android:id="@+id/my_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:choiceMode="singleChoice"
/>
प्रत्येक सूची आइटम के लिए लेआउट (list_item.xml) है:
my_list = (ListView) findViewById(R.id.my_list);
SimpleAdapter adapter = new SimpleAdapter(context, getOptions(),
R.layout.list_item,
new String[] { "icon1","str1" },
new int[] {R.id.my_icon, R.id.my_str });
my_list.setAdapter(adapter);
//onClickListener does not work after I added RadioButton in list item layout
my_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Log.v("SELECTED", position+"");
}
});
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
>
<ImageView
android:id = "@+id/my_icon"
android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
android:layout_centerVertical="true"
/>
<TextView
android:id="@+id/my_str"
android:layout_width="wrap_content"
android:layout_height = "wrap_content"
android:layout_toRightOf="@id/my_icon"
/>
<!--This radio button makes the list item unselectable, why?-->
<RadioButton
android:id="@+id/my_radio_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
जावा कोड में, मैं सूची के लिए SimpleAdapter
का उपयोग
जैसा कि आप देखते हैं, उपरोक्त कोड में, सूची आइटम लेआउट में, मैंने RadioButton
जोड़ा, इस बटन को जोड़ने के बाद, मेरी सूची onClickListener
अब और काम नहीं करती है, क्यों ?? (यह काम करता है अगर यह सूची आइटम लेआउट पर RadioButton
बिना है)
क्योंकि अब हो रहा ** फोकस ** है कि आइटम – waqaslam
के अंदर अपने सूचीदृश्य के मद और रेडियो बटन के बीच की अपनी एक संघर्ष तो इस समस्या से छुटकारा पाने के लिए? मुझे सूची आइटम पर रेडियो बटन चाहिए, और जब उपयोगकर्ता आइटम क्षेत्र पर क्लिक करता है तो मुझे रेडियो बटन का चयन करने की आवश्यकता होती है। –
क्लिक श्रोता केवल तभी काम करता है जब कोई अन्य दृश्य फोकस करने योग्य न हो। अपने चेकबॉक्स को फोकस करने योग्य = "झूठी" को आपके लिए चाल करना चाहिए http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items –