我正在使用带有黄瓜的webrat,我想测试当我在页面上时是否已经检查了一个单选按钮.我怎样才能做到这一点 ?我没有在webrat中找到任何可以做到这一点的步骤.
我有一个包含很多无线电组的表格.每个无线电都具有唯一的ID,并且与其组中的其他无线电具有相同的名称.该页面验证为XHTML过渡.
在IE6和7,Opera,Safari和Chrome中进行测试,它的工作方式与鼠标或键盘输入的完全一致.
在FireFox中它变得疯狂.只需单击组中的任何无线电,即可选中组中的第一个无线电.双击收音机通常会选择它.有人见过这个吗?
示例组如下所示:
<input type="radio" name="upAndDown_1" id="upAndDown_11" value="Y" /> Y <br />
<input type="radio" name="upAndDown_1" id="upAndDown_12" value="N" checked="checked" /> N<br />
<input type="radio" name="upAndDown_1" id="upAndDown_13" value="NA" /> NA
Run Code Online (Sandbox Code Playgroud)
可以在此处测试这种现象:http://www.nolaflash.com/stackoverflow/firefox_and_radios.html
任何建议表示赞赏
我有以下单选按钮,默认情况下都没有选中.
<input type="radio" name="location" value="0" /> home
<input type="radio" name="location" value="1" /> work
<input type="radio" name="location" value="2" /> school
Run Code Online (Sandbox Code Playgroud)
如何检测其中任何一个被检查.我正在寻找像点击这样的东西,但它不起作用
$("input[name=location]").click(function(){
alert("selected");
});
Run Code Online (Sandbox Code Playgroud) 我正在使用包含一组单选按钮的无线电组的Android表单.据我所知,当您选择它时,无法设置单选按钮突出显示的颜色.它似乎总是默认为一些亮绿色.这是可编辑的还是不可编辑的?
谢谢
这是我目前的布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#F5F5DC"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<RadioButton android:id="@+id/radio_red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/flag_dk"
android:textColor="#000000"
android:layout_gravity="center_horizontal"
android:drawablePadding="10dip"
android:text="Danish" />
<RadioButton android:id="@+id/radio_blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/flag_en"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dip"
android:drawablePadding="10dip"
android:textColor="#000000"
android:text="English" />
</RadioGroup>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我明白了:

我想在radiobutton和旗帜之间有一些空间(边距)(它是可绘制的).它甚至可能吗?
我以为我擅长WinForms的东西,但显然事实并非如此.
此应用程序适用于触摸屏硬件.我只想让其中一个按钮保持按下,所以我把它们做成了带外观的单选按钮Button.它运作良好,但我无法控制它们的大小,如宽度和高度.单选按钮大小由其文本和字体大小控制.如果这是针对常见的Windows应用程序,这不是问题.但这是一个问题,因为我正在为触摸屏开发它.
如何控制单选按钮的大小?
我已经在我的应用程序中自定义了所有的radioButtons,但listPreference中的radioButtons没有自定义.
我使用了这个名为btn_radio.xml的xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_window_focused="false"
android:drawable="@drawable/radio_selected" />
<item android:state_checked="false" android:state_window_focused="false"
android:drawable="@drawable/radio_unselected" />
<item android:state_checked="true" android:state_pressed="true"
android:drawable="@drawable/radio_selected" />
<item android:state_checked="false" android:state_pressed="true"
android:drawable="@drawable/radio_unselected" />
<item android:state_checked="true" android:state_focused="true"
android:drawable="@drawable/radio_selected" />
<item android:state_checked="false" android:state_focused="true"
android:drawable="@drawable/radio_unselected" />
<item android:state_checked="false" android:drawable="@drawable/radio_unselected" />
<item android:state_checked="true" android:drawable="@drawable/radio_selected" />
</selector>
Run Code Online (Sandbox Code Playgroud)
这是customRadioButton,它扩展了android自定义单选按钮
<style name="CustomRadioButton" Parent="@android:style/Widget.CompoundButton.RadioButton">
<item name="android:button">@drawable/btn_radio</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在我的应用程序的主题中,我做了这个改变
<item name="android:radioButtonStyle">@style/CustomRadioButton</item>
<item name="android:listChoiceIndicatorSingle">@style/CustomRadioButton</item>
Run Code Online (Sandbox Code Playgroud)
此更改会自定义我的应用程序中的所有radioButtons,但ListPreference中的radioButtons除外
我在xml中有一个radiogroup,按钮是以编程方式生成的.如何以编程方式在按钮之间添加间距.
我认为这是类似的东西,LayoutParams但我的对象没有明显setPadding或setMargins方法.
这就是我的尝试
RadioButton currentButton = new RadioButton(context);
currentButton.setText(item.getLabel());
currentButton.setTextColor(Color.BLACK);
//add padding between buttons
LayoutParams params = new LayoutParams(context, null);
params. ... ??????
currentButton.setLayoutParams(params);
Run Code Online (Sandbox Code Playgroud) 我是Android的新手,我需要在我的活动上添加单选按钮,但我需要将文本放在项目符号按钮上.
请帮忙.我找到了以下内容,虽然我不明白@ drawable/main_selector和@ style/TabStyle是什么.
任何人都可以给我一个101指南.
UPDATE
我根据一些建议使用了以下内容,但没有奏效:
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<RadioButton
android:text="something that is on top"
android:id="@+id/toggle_tab_left"
android:button="?android:attr/listChoiceIndicatorSingle"
style="@null"/>
<RadioButton
android:button="?android:attr/listChoiceIndicatorSingle"
android:text="something that is on top"
android:id="@+id/toggle_tab_right"
style="@null"/>
</RadioGroup>
Run Code Online (Sandbox Code Playgroud)
更新2
我从Warpzit得到了我的解决方案,但是因为我将问题标记为已回答,有人可以帮我解决下面的对齐问题.我将连续有5个单选按钮,其中一些将有更长的文本分成2行.当文本适合屏幕,因为横向或平板电脑,那么所有文本应该在一行中:

更新3
...根据屏幕大小,文本可以分成不同数量的行.它永远不会是标准的

说我有一个枚举:
public enum OrderStatusType
{
Waiting = 0,
Pending,
Picked,
Shipped,
}
Run Code Online (Sandbox Code Playgroud)
我按如下方式生成单选按钮列表.
@Html.RadioButtonFor(m => m.Status, OrderStatusType.Shipped, new {@checked = true})
@Html.RadioButtonFor(m => m.Status, OrderStatusType.Waiting)
Run Code Online (Sandbox Code Playgroud)
但等待总是被选中.输出HTML如下:
input type="radio" value="Shipped" name="Status" id="Status" checked="True"
input type="radio" value="Waiting" name="Status" id="Status" checked="checked"
Run Code Online (Sandbox Code Playgroud)
为什么MVC框架会自动添加"已检查"属性?谢谢.
该模型:
public class OrderViewModel
{
public OrderStatusType Status { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
风景:
@using WebApplication17.Controllers
@model WebApplication17.Models.OrderViewModel
@{
ViewBag.Title = "Home Page";
}
@Html.RadioButtonFor(m => m.Status, OrderStatusType.Picked)
<span>@OrderStatusType.Picked</span>
@Html.RadioButtonFor(m=>m.Status, OrderStatusType.Pending)
<span>@OrderStatusType.Pending</span>
@Html.RadioButtonFor(m => m.Status, OrderStatusType.Shipped, new {@checked = true})
<span>@OrderStatusType.Shipped</span> …Run Code Online (Sandbox Code Playgroud) radio-button ×10
android ×5
margin ×2
.net ×1
c# ×1
checked ×1
cucumber ×1
drawable ×1
firefox ×1
html-helper ×1
javascript ×1
jquery ×1
padding ×1
radio-group ×1
webrat ×1
winforms ×1