Sto cercando di impostare la visibilità per un pulsante come segue setVisibility():Non in grado di impostare dinamicamente il parametro
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;
}
Ma sto ottenendo l'errore:
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.
durante la chiamata
getVisibilityState(bundle, PersistanceConstants.START_BTN_STATE)
Non so come aggirare questo. Comprendo che si aspetta un dato insieme di valori, ma tutto quello che so è di passare un int
ad esso. Cosa si può fare qui?
inserisci il tuo log degli errori .. – Sats
getVisibilityState raggiungere la riga 'return 0;'? per favore, pubblica il tuo log degli errori. – wendigo
Mi spiace di non averlo menzionato. Sto ottenendo questo durante la compilazione in studio Android. – jsbisht