标签: unchecked

如何在不取消选中的情况下执行此操作?

几个月前我编写了这段代码,因为这是我能想到的唯一方法(在学习C#的同时).你会怎么做?是unchecked这样做的正确方法?

unchecked //FromArgb takes a 32 bit value, though says it's signed. Which colors shouldn't be.
{
  _EditControl.BackColor = System.Drawing.Color.FromArgb((int)0xFFCCCCCC);
}
Run Code Online (Sandbox Code Playgroud)

c# unchecked

5
推荐指数
2
解决办法
317
查看次数

检查在运行时发生的异常?

我对java的运行时异常的命名感到困惑.那些经过检查的异常,比如SQLexception,也会在程序执行期间发生.为什么只有那些未经检查的那些称为运行时异常?可能我对"运行时"有误解.

谢谢你的任何建议.

java exception unchecked runtimeexception

5
推荐指数
1
解决办法
856
查看次数

优化C#代码片段

我正在分析一些C#代码.以下方法是最昂贵的方法之一.出于这个问题的目的,假设微观优化是正确的.有没有办法提高这种方法的性能?

将输入参数更改pulong[]将导致宏效率低下.

static ulong Fetch64(byte[] p, int ofs = 0)
{
    unchecked
    {
        ulong result = p[0 + ofs] + 
            ((ulong) p[1 + ofs] <<  8) + 
            ((ulong) p[2 + ofs] << 16) + 
            ((ulong) p[3 + ofs] << 24) + 
            ((ulong) p[4 + ofs] << 32) + 
            ((ulong) p[5 + ofs] << 40) + 
            ((ulong) p[6 + ofs] << 48) + 
            ((ulong) p[7 + ofs] << 56);
        return result;
    }
}
Run Code Online (Sandbox Code Playgroud)

c# unchecked micro-optimization

5
推荐指数
1
解决办法
646
查看次数

将-1转换为uint C#

将-1转换为uint将不起作用"((uint)( - 1))"解决方案?

num10 = ((uint)(-1)) >> (0x20 - num9);
Run Code Online (Sandbox Code Playgroud)

错误:常量值'-1'无法转换为'uint'(使用'unchecked'语法覆盖)

c# overriding unchecked uint

5
推荐指数
2
解决办法
9408
查看次数

无法取消选中动态广播组中已检查的单选按钮

如果我第一次设置一个单选按钮,它可以正常工作.但如果我通过调用.setChecked(false)取消选择它; 然后,即使我试图通过调用setChecked(true)来选择它也不会取消选择前一个.

    private void radiotype() {
    count = //changed every time.
    LinearLayout llques = (LinearLayout) mview.findViewById(R.id.llrbgRBD);
    RadioGroup group = new RadioGroup(context);
    group.setOrientation(RadioGroup.VERTICAL);
    final RadioButton[] rb = new RadioButton[count];
    List<String[]> ans = getAnswerList.getAns();

    for (int j = 0; j < count; j++) {

        rb[j] = new RadioButton(context);
        rb[j].setVisibility(View.VISIBLE);
        rb[j].setText("`enter code here`hi");
        String a = rb[j].getText().toString();`enter code here`
        Log.e("getAnswerList===a", "getAnswerList===>a" + a);
        Log.e("getAnswerList", "getAnswerList===>" + ans.get(index)[0]);
        if (a.equalsIgnoreCase(ans.get(index)[0])) {
            rb[j].setChecked(true);
        }
        rb[j].setTextColor(Color.BLACK);
        rb[j].setButtonDrawable(R.drawable.custom_radio_button);
        group.addView(rb[j]);
    }
    llques.removeAllViews();
    llques.addView(group);
    group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void …
Run Code Online (Sandbox Code Playgroud)

android unchecked radio-button

5
推荐指数
2
解决办法
2441
查看次数

如何在没有广播组的情况下取消选中单选按钮?

我已经使用以下代码片段来设置一个单选按钮以取消选中另一个单选按钮,但是当我运行应用程序并选择两个单选按钮时,代码不起作用,因为两者都保持选中状态.

我正在使用相对布局,所以我不能使用任何其他解决方案与无线电组,我只是使用两个单独的单选按钮.

有人可以指出我在哪里可能出错了,因为我看不出逻辑中的缺陷,任何想法?

无论如何,这是我试图实现的解决方案,但它不适用于应用程序:

public void onRadioButtonClicked(View view) {
        // Is the button now checked?
        boolean checked = ((RadioButton) view).isChecked();

        // Check which radio button was clicked
        switch(view.getId()) {
            case R.id.radBtnMM:
                if (checked)
                    //set inch button to unchecked
                     radioInch.setChecked(false);
                break;
            case R.id.radBtnInch:
                if (checked)
                    //set MM button to unchecked
                    radioMM.setChecked(false);
                break;
        }
    }
Run Code Online (Sandbox Code Playgroud)

android unchecked radio-button

5
推荐指数
1
解决办法
8645
查看次数

jquery按钮取消选中复选框

大家好,这个任务似乎很容易,虽然我的代码不起作用.

我有一些行的表,每行有一个复选框,在下面我把按钮"全部删除"取消选中复选框.这是我的代码:

    $('#remove-button').click(function(){
        $('input:checked').prop('checked',false);
        //e.stopPropagation(); // I tried also with this
        // $('input:checked').removeAttr('checked'); // or this syntax
    });
Run Code Online (Sandbox Code Playgroud)

当我点击按钮时,所有输入都是未选中的,但由于我的代码不会发生这种情况,因为当我评论此片段时,当我点击按钮时也会发生这种情况.我也看到,当我点击并且输入未被选中时,我的网站似乎刷新了,因为页面空洞.

我还添加了另一个按钮来检查输入:

    $('#add-button').click(function(e){
        $('input').prop('checked',true);
        //e.stopPropagation(); // I tried also with this
        // $('input:checked').removeAttr('checked'); // or this syntax
    });
Run Code Online (Sandbox Code Playgroud)

当我点火这个输入被检查,一秒钟我的网站刷新,一切都消失了.

我使用最新的Firefox和Chrome,以及jQuery - 1.11(但也检查了1.8.0和1.7.1).还有一些问题

谁知道什么是错的?

jquery button unchecked

5
推荐指数
1
解决办法
3628
查看次数

android未经检查的单选按钮已经检查过

<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rg"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.radiogroup.MainActivity" >

    <RadioButton
        android:id="@+id/rb_true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_vertical" />

    <RadioButton
        android:id="@+id/rb_false"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_vertical" />

</RadioGroup>
Run Code Online (Sandbox Code Playgroud)

我有一个广播组,其中我有2个单选按钮

现在,如果选择单选按钮1,如果我点击相同的单选按钮(单选按钮1),则应该取消选中它.

它应该像切换一样工作.

android unchecked radio-button

5
推荐指数
1
解决办法
2万
查看次数

我如何摆脱这些(未经检查的电话)警告?

warning: [unchecked] unchecked call to setCellValueFactory(Callback<CellDataFeatures<S,T>,ObservableValue<T>>) as a member of the raw type TableColumn column1.setCellValueFactory(new PropertyValueFactory<String, State>("name"));   where S,T are type-variables:
    S extends Object declared in class TableColumn
    T extends Object declared in class TableColumn
Run Code Online (Sandbox Code Playgroud)

码:

column1.setCellValueFactory(new PropertyValueFactory<>("name"));
Run Code Online (Sandbox Code Playgroud)
warning: [unchecked] unchecked call to add(E) as a member of the raw type List
            transitionTable.getColumns().add(column1);
  where E is a type-variable:
    E extends Object declared in interface List
Run Code Online (Sandbox Code Playgroud)

码:

transitionTable.getColumns().add(column1);
Run Code Online (Sandbox Code Playgroud)
warning: [unchecked] unchecked call to setAll(Collection<? extends E>) as a member of the …
Run Code Online (Sandbox Code Playgroud)

java generics warnings javafx unchecked

5
推荐指数
1
解决办法
5508
查看次数

使用Mockito时避免未经检查的警告

我想在调用方法时模拟调用on ScheduledExecutorService来返回ScheduledFuture类的mock schedule.以下代码编译并正常工作:

    ScheduledExecutorService executor = Mockito.mock(ScheduledExecutorService.class);
    ScheduledFuture future = Mockito.mock(ScheduledFuture.class);
    Mockito.when(executor.schedule(
        Mockito.any(Runnable.class),
        Mockito.anyLong(),
        Mockito.any(TimeUnit.class))
    ).thenReturn(future); // <-- warning here
Run Code Online (Sandbox Code Playgroud)

除了我在最后一行得到未经检查的警告:

found raw type: java.util.concurrent.ScheduledFuture
  missing type arguments for generic class java.util.concurrent.ScheduledFuture<V>

 unchecked method invocation: method thenReturn in interface org.mockito.stubbing.OngoingStubbing is applied to given types
  required: T
  found: java.util.concurrent.ScheduledFuture

unchecked conversion
  required: T
  found:    java.util.concurrent.ScheduledFuture
Run Code Online (Sandbox Code Playgroud)

是否有可能以某种方式避免这些警告?

代码就像ScheduledFuture<?> future = Mockito.mock(ScheduledFuture.class);不编译.

java unchecked mockito

5
推荐指数
1
解决办法
3651
查看次数