我在使用ListPreference时遇到一些问题,当我使用ListPreference.setEntries()和ListPreference.setEntryValues()设置值时,则设置了值,但未检查,我尝试了ListPreference.setEnabled(true)和ListPreference .setSelectable(true),但它是关于ListPreference,而不是ListPreference中的值,在设置值后用编码检查它的任何方法?
谢谢
java 文档说检查异常必须指定可以“捕获”异常或在方法声明中抛出异常的处理程序。但是,如果我这样做,例如:
public class DivZero{
public static void main(String[] args){
int a=10;
int[] b={1,2,3,4,0};
for (int i=0;i<b.length;i++){
System.out.println(a/b[i]);
}
}
}
Run Code Online (Sandbox Code Playgroud)
它也可以在没有“try-catch”或“throws”声明的情况下正常工作。它抛出一个java.lang.ArithmeticException。那么,这不是强制性的吗?编译器以相同的方式隐式抛出合适的 Java“Throwable”类。是这样吗?
我正在尝试根据用户检查的单选按钮向div添加文本,但无论选中哪个属性,它都会触发"else"块,并且每次都显示"female".
请帮忙!
<input type="radio" name="gender" class="gender" id="male" value="male">Male<br />
<input type="radio" name="gender" class="gender" id="female" value="female">Female<br />
$(".gender").change(function () {
if ($("#male").attr("checked")) {
$("#content").text("male");
}
else {
$("#content").text("female");
}
});
Run Code Online (Sandbox Code Playgroud) 所以我有一个自动生成的div,里面有3个不同的ID和名称的复选框,默认情况下都没有被检查!如果有人碰巧检查,那么我需要另外两个未经检查!
因此,一次只能检查一个......
所以所有未检查或只检查一个!
<div class="configoptions">
<table class="configtable" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td class="fieldlabel">Include:</td>
<td class="fieldarea">
<label><input name="configoption[10]" id="co30" value="1" onclick="recalc()" type="checkbox">green</label>
</td>
</tr>
<tr>
<td class="fieldlabel">Include:</td>
<td class="fieldarea">
<label><input name="configoption[9]" id="co27" value="1" onclick="recalc()" type="checkbox">blue</label>
</td>
</tr>
<tr>
<td class="fieldlabel">Include:</td>
<td class="fieldarea">
<label><input name="configoption[11]" id="co31" value="1" onclick="recalc()" type="checkbox">white</label>
</td>
</tr>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我以前取消选中页面准备好的所有div的原因..因为最初我需要它们取消选中..这很有效...现在我需要制作它所以只有一个是检查,如果它被检查!有人能给我一个手吗?Thx提前!
$(document).ready(function() {
$('input[type=checkbox]').each(function() {
this.checked = false;
});
});
Run Code Online (Sandbox Code Playgroud) 我一直试图检查我的输入[type = hidden]是否有checked ="checked"属性.该输入字段如下所示:
<input type="hidden" checked="checked" name="1_WILLINFOS">
Run Code Online (Sandbox Code Playgroud)
在Firefox中,通过使用它可以正常工作:
jQuery(selector).find('input[name=1_WILLINFOS]').attr('checked') == "checked"
Run Code Online (Sandbox Code Playgroud)
但IE10总是给我一个假的.
到现在为止我尝试使用以下内容:
.attr("checked") == "checked"
.attr("checked") == true
.is(':checked')
Run Code Online (Sandbox Code Playgroud)
所有这些都给了我一个假的.
有任何想法吗?谢谢
我已经用一个项目列表填充了一个QListWidget,并添加了一个复选框,使所有内容都未选中.
for td in root.iter('testdata'):
test_data = td.get('ins')
item = QtGui.QListWidgetItem(test_data, self.listWidgetLabels)
item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
item.setCheckState(QtCore.Qt.Unchecked)
Run Code Online (Sandbox Code Playgroud)
然后,用户单击QListItem中的一些项目,然后单击gui上的"生成文件"按钮.
self.pushButtonGenerateFile.clicked.connect(self.generate_file)
Run Code Online (Sandbox Code Playgroud)
我想获得所有已检查的QListItem的列表.
def generate_driver(self):
test = self.listWidgetLabels.selectedItems()
items = []
checked_items = []
for index in range(self.listWidgetLabels.count()):
items.append(self.listWidgetLabels.item(index))
for x in self.listWidgetLabels.selectedItems():
checked.append(x.text())
for i in checked:
print("Checked Items: {0}".format(i))
Run Code Online (Sandbox Code Playgroud)
上面的内容获取列表中的selectedItem.我试过getState(),getChecked(),但QListWidget项不存在.
任何线索都非常感谢.
谢谢,
约翰.
我正在为电子商务使用基于复选框的过滤器。一切正常,但是当我尝试通过“后退”按钮返回时,复选框仍处于选中状态,而没有任何选中的属性。
我注意到此“问题”发生在:
我发现的唯一方法就是重新加载页面。但是“用户回退”事件似乎不是可捕获的,而且我不想刷新每个页面。
将我的所有复选框都设置为默认设置没有任何意义。
禁用Chrome缓存无效。
我不知道我的代码示例是否有用
编辑:这是我的第一篇文章,所以请务必告诉我为什么我的问题似乎不清楚
我有一个复选框,需要根据函数结果显示为选中,而不是将其绑定到对象属性.
这很容易,但不可能:
<input type="checkbox" ([ngModel])="category.selected">
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为甚至会checked="false"导致复选框显示为已选中:
<input type="checkbox" [attr.checked]="isCategorySelected(category.id)"/>
Run Code Online (Sandbox Code Playgroud)
我需要这样的结果
<input type="checkbox">
<input type="checkbox" checked>
Run Code Online (Sandbox Code Playgroud)
取决于结果isCategorySelected(id).
任何帮助表示赞赏.
我需要制作 5 个复选框,它们都有一个值,从 1 到 5,当我选中一个时,我需要在文本框中打印出值,我可以取消选中这些框,数字就会消失。我的问题在于取消选中部分,我似乎找不到一种方法来在未选中的情况下从文本框中删除该值..我尝试过
if( aInput[0].checked == false){
aTxt[0].value = aInput[0].value;
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用
如果我的 v-model 是一个数组,我如何检查 v-for 中的单选按钮?
我的数据:
data() {
return {
persons: {
name: [],
surname: [],
sex: [],
}
}
}
Run Code Online (Sandbox Code Playgroud)
还有我的收音机:
<template v-for(person, person_index) in persons>
<div class="switch-sex">
<input type="radio" name="sex" :id="'male'+person_index" value="male"
v-model="persons.sex[person_index]">
<label :for="'male' + person_index">M</label>
<input type="radio" name="sex" :id="'female' + person_index"
value="female" v-model="persons.sex[person_index]">
<label :for="'female' + person_index">F</label>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我需要在 v-for 中的每个人中检查我的第一台收音机(男)