问题描述
- android ListView中的Item有两行Button,要求实现单选效果,应该怎么做呢?
-
就是向这样的Button,在ListView的Item中,如果有两行,要能实现单选效果,应该怎么做呢?麻烦各位大神们说详细点~~
解决方案
这个不用button,用radiobutton。
解决方案二:
我是在RadioGroup中嵌套了一个LinearLayout,这样就可以显示两行了,那么问题来了,radiogroup不能实现单选了,怎么办啊
解决方案三:
我是在RadioGroup中嵌套了一个LinearLayout,这样就可以显示两行了,那么问题来了,radiogroup不能实现单选了,怎么办啊
解决方案四:
我是在RadioGroup中嵌套了一个LinearLayout,这样就可以显示两行了,那么问题来了,radiogroup不能实现单选了,怎么办啊
解决方案五:
这不是Button,这是RadioButton
解决方案六:
我知道是RadioButton,只是在RadioButton的外面套了个LinearLayout,便不能实现单选了,
android:id="@+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="false"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/btn_first_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/item_8"
android:layout_weight="1"
android:background="@drawable/btn_addshoppingcard_selector"
android:button="@null"
android:checked="true"
android:clickable="true"
android:focusable="false"
android:gravity="center"
android:paddingBottom="@dimen/item_8"
android:paddingTop="@dimen/item_8"
android:textColor="@color/text_color"
android:textSize="@dimen/text_size_12" />
<RadioButton
android:id="@+id/btn_first_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/item_8"
android:layout_weight="1"
android:background="@drawable/btn_addshoppingcard_selector"
android:button="@null"
android:clickable="true"
android:focusable="false"
android:gravity="center"
android:paddingBottom="@dimen/item_8"
android:paddingTop="@dimen/item_8"
android:textColor="@color/text_color"
android:textSize="@dimen/text_size_12" />
<RadioButton
android:id="@+id/btn_first_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/item_8"
android:layout_weight="1"
android:background="@drawable/btn_addshoppingcard_selector"
android:button="@null"
android:clickable="true"
android:focusable="false"
android:gravity="center"
android:paddingBottom="@dimen/item_8"
android:paddingTop="@dimen/item_8"
android:textColor="@color/text_color"
android:textSize="@dimen/text_size_12" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/btn_second_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/item_8"
android:layout_weight="1"
android:background="@drawable/btn_addshoppingcard_selector"
android:button="@null"
android:clickable="true"
android:focusable="false"
android:gravity="center"
android:paddingBottom="@dimen/item_8"
android:paddingTop="@dimen/item_8"
android:textColor="@color/text_color"
android:textSize="@dimen/text_size_12" />
<RadioButton
android:id="@+id/btn_second_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/item_8"
android:layout_weight="1"
android:background="@drawable/btn_addshoppingcard_selector"
android:button="@null"
android:clickable="true"
android:focusable="false"
android:gravity="center"
android:paddingBottom="@dimen/item_8"
android:paddingTop="@dimen/item_8"
android:textColor="@color/text_color"
android:textSize="@dimen/text_size_12" />
<RadioButton
android:id="@+id/btn_second_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/item_8"
android:layout_weight="1"
android:background="@drawable/btn_addshoppingcard_selector"
android:button="@null"
android:clickable="true"
android:focusable="false"
android:gravity="center"
android:paddingBottom="@dimen/item_8"
android:paddingTop="@dimen/item_8"
android:textColor="@color/text_color"
android:textSize="@dimen/text_size_12" />
</LinearLayout>
</RadioGroup>
时间: 2024-08-31 10:34:20