
我有一个RadioGroup,其中提供了四个不同的单选按钮,其文本分别为:
<RadioGroup androID:ID="@+ID/radio_group" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:layout_marginleft="2dp" androID:layout_marginRight="1dp" androID:background="@color/textbackgroundcolor" androID:paddingBottom="10dp" androID:paddingtop="10dp" androID:soundEffectsEnabled="true" > <Radiobutton androID:ID="@+ID/radio_one" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginleft="5dp" androID:checked="false" androID:textcolor="@color/black" androID:textStyle="bold" androID:textSize="12dp"/> <Radiobutton androID:ID="@+ID/radio_two" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginleft="5dp" androID:checked="false" androID:textcolor="@color/black" androID:textStyle="bold" androID:textSize="12dp"/> <Radiobutton androID:ID="@+ID/radio_three" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginleft="5dp" androID:checked="false" androID:textcolor="@color/black" androID:textStyle="bold" androID:textSize="12dp"/> <Radiobutton androID:ID="@+ID/radio_four" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginleft="5dp" androID:checked="false" androID:textcolor="@color/black" androID:textStyle="bold" androID:textSize="12dp"/> </RadioGroup>到目前为止,它显示带有其文本的单选按钮.但是我想在每个单选按钮之前显示一些标签/数字.
如何为单选按钮提供1、2、3、4之类的数字?
解决方法:
有不同的方法可以做到这一点.但是想到的最简单的方法是在每个TextVIEw之前添加一个TextVIEw并将其与每个RadioButten一起放置在linearLayout中
<RadioGroup androID:ID="@+ID/radio_group" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:layout_marginleft="2dp" androID:layout_marginRight="1dp" androID:background="@color/textbackgroundcolor" androID:paddingBottom="10dp" androID:paddingtop="10dp" androID:soundEffectsEnabled="true" > <linearLayout > <TextVIEw androID:layout_wIDth="fill_parent" androID:minlines="2" androID:gravity="center" androID:textSize="15dp" androID:text="1" androID:layout_height="wrap_content"/> <Radiobutton androID:ID="@+ID/radio_one" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:textcolor="@color/black" androID:layout_marginleft="5dp" androID:checked="false" androID:textStyle="bold" androID:textSize="12dp"/> </linearLayout></RadioGroup>这是一般的想法
总结以上是内存溢出为你收集整理的如何在android中为单选按钮提供编号?全部内容,希望文章能够帮你解决如何在android中为单选按钮提供编号?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)