samedi 27 juin 2015

Saving state of `EditText` visibility

I have couple of editTexts that are set to VISIBLE and INVISIBLE by a button click. I tried saving the state of visibility or invisibility using a Boolean and setting it to True when it became VISIBLE and setting it to False when it was INVISIBLE. I don't know why but it didn't save the state. Can someone show me an example or steer me the right way to save the state of the editText's visibility. I'm an android newbie, any help would be appreciated, thanks.

public void Visible() { ////this button click will make the editext visible, if it is invisible
if(e1.getVisibility() == View.INVISIBLE){
    e1.setVisibility(View.VISIBLE);
} else if(e2.getVisibility() == View.INVISIBLE){
    e2.setVisibility(View.VISIBLE);
 }
 }
 public void invisible(){ //this button click will make the editext invisible, if it is visible
if(e2.getVisibility() == View.VISIBLE)
{
    e2.setVisibility(View.INVISIBLE);
}
else if(e1.getVisibility() == View.VISIBLE){
    e1.setVisibility(View.INVISIBLE);
}
 }

Aucun commentaire:

Enregistrer un commentaire