我想设置的可视性按钮如下:不能够动态地设置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
它。这里可以做些什么?
发布您的错误日志.. – Sats 2014-10-01 10:22:35
getVisibilityState达到'返回0;'行?请发布您的错误日志。 – wendigo 2014-10-01 10:24:43
对不起,我没有提到这一点。我在Android Studio编译期间得到了这个。 – jsbisht 2014-10-01 10:27:22