java setmodal 不管用_java – 无法动态设置setVisibility()参数

我正在设置一个按钮的可见性,如下所示:

public Bundle setActivityState(Bundle bundle){

startBtn = (Button) findViewById(R.id.startSensorsBtn);

startBtn.setVisibility(

getVisibilityState(bundle,PersistanceConstants.START_BTN_STATE)

);

return bundle;

}

public int getVisibilityState(Bundle bundle,String keyName){

if (bundle.getInt(keyName) == View.VISIBLE){

return View.VISIBLE;

} else if (bundle.getInt(keyName) == View.INVISIBLE){

return View.INVISIBLE;

} else if (bundle.getInt(keyName) == View.GONE){

return View.GONE;

}

return 0;

}

但我收到错误:

Must be one of: View.VISIBLE,View.INVISIBLE,View.GONE less... (Ctrl+F1)

Reports two types of problems:

- Supplying the wrong type of resource identifier. For example,when calling Resources.getString(int id),you should be passing R.string.something,not R.drawable.something.

- Passing the wrong constant to a method which expects one of a specific set of constants. For example,when calling View#setLayoutDirection,the parameter must be android.view.View.LAYOUT_DIRECTION_LTR or android.view.View.LAYOUT_DIRECTION_RTL.

而打电话

getVisibilityState(bundle,PersistanceConstants.START_BTN_STATE)

我不知道如何解决这个问题.我明白,它期待一组给定的值,但我知道的只是传递一个int.这里可以做些什么?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值