Próbuję ustawić widoczność przycisku w następujący sposób:Nie stanie dynamicznie ustawić setVisibility() parametr
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;
}
Ale otrzymuję błąd:
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.
podczas wywoływania
getVisibilityState(bundle, PersistanceConstants.START_BTN_STATE)
Nie wiem, jak sobie z tym poradzić. Rozumiem, że oczekuje on określonego zestawu wartości, ale wiem tylko, że przekazałem do niego numer int
. Co można tutaj zrobić?
opublikuj swój dziennik błędów .. – Sats
getVisibilityState osiągnie linię 'return 0;'? proszę, opublikuj swój dziennik błędów. – wendigo
Niestety, nie wspomniałem o tym. Otrzymuję to podczas kompilacji w Androidzie. – jsbisht