由网友(人未死,心先死 °)分享简介:我想设置的可见性按钮,如下所示:I am trying to set the visibility for a button as follows:public Bundle setActivityState(Bundle bundle){startBtn = (Button) findViewById(R.id....
我想设置的可见性按钮,如下所示:
I am trying to set the visibility for a button as follows:
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;
}
但我得到的错误:
But I am getting the error:
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
给它。有什么方法可以在这里做什么?
I don't know how to get around this. I understand that it's expecting a given set of values but all I know is to pass an int
to it. What can be done here?
推荐答案
当你知道自己在做什么,你可以在此Android的工作室考察当地燮preSS与
When you know what you're doing, you can suppress this Android Studio inspection locally with
//noinspection ResourceType
例如,
//noinspection ResourceType
startBtn.setVisibility(bundle.getInt(PersistanceConstants.START_BTN_STATE));
相关推荐
最新文章