gpt4 book ai didi

Android RadioGroup - 它可以与内部的其他组件一起使用吗?

转载 作者:行者123 更新时间:2023-11-30 03:18:12 39 4
gpt4 key购买 nike

我的想法是让 ImageView - RadioButton 成对,每对包含在 LinearLayout(水平方向)和 ImageButtons 中,当选择并确认一个选项时,它们的背景颜色会改变。所以,它看起来像:

[LinearLayout1]: [ImageView1] [RadioButton1]
[LinearLayout2]: [ImageView2] [RadioButton2]
[LinearLayout3]: [ImageView3] [RadioButton3]

是否可以将此层次结构存储在 RadioGroup 中?我尝试应用它,但在我的应用程序中看不到 ImageView。或者 RadioGroup 是否仅为 RadioButtons 而忽略所有其他 View ?

最佳答案

是的,这是可能的。如果它不起作用,则说明您的代码存在其他问题。

基于 SDK 中包含的 ApiDemos 示例 Android 应用的概念布局证明:

<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:checkedButton="@+id/lunch"
android:id="@+id/menu">

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/radio_group_1_breakfast"
android:id="@+id/breakfast"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star"/>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/radio_group_1_lunch"
android:id="@id/lunch"/>
</LinearLayout>

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/radio_group_1_dinner"
android:id="@+id/dinner"/>


<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/radio_group_1_all"
android:id="@+id/all"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/radio_group_1_selection"
android:id="@+id/choice"/>
</RadioGroup>

及其生成的布局:

Radio buttons

关于Android RadioGroup - 它可以与内部的其他组件一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19670368/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com