user1483756
user1483756

Reputation:

Change EditText Visibility To Hidden

I want to change EditText visibility to hidden when a button click. I write a code, but it doesn't work. How can I do it?

This is my code:

public void onClick(View view) {
        if(((Button)findViewById(R.id.login)).getId() == ((Button)view).getId())
            findViewById(R.id.google_account).setVisibility(0); 
}

Upvotes: 0

Views: 3569

Answers (5)

Kumar Vivek Mitra
Kumar Vivek Mitra

Reputation: 33534

We have constants like View.INVISIBLE,View.VISIBLE, View.GONE, we can also use integer constants like Visible = 0 , Gone = 8 etc...

Eg:

public void onClick(View view) {
        if(((Button)findViewById(R.id.login)).getId() == ((Button)view).getId())
            findViewById(R.id.google_account).setVisibility(View.GONE); 

                                  OR

            findViewById(R.id.google_account).setVisibility(View.INVISIBLE); 
}

Upvotes: 0

Ran
Ran

Reputation: 4157

0 means visible.

It's better to use the constants:

View.VISIBLE, View.GONE or View.INVISIBL.

http://developer.android.com/reference/android/view/View.html

Upvotes: 5

Ilya Demidov
Ilya Demidov

Reputation: 3305

public void onClick(View view) {
        if((Button)findViewById(R.id.login) == view)
            findViewById(R.id.google_account).setVisibility(View.GONE); 
}

Upvotes: 1

ρяσѕρєя K
ρяσѕρєя K

Reputation: 132982

Try to set EditText View.GONE as:

EditText txtx=(EditText)findViewById(R.id.google_account);
txtx.setVisibility(View.GONE);

or

findViewById(R.id.google_account).setVisibility(View.GONE);

Upvotes: 1

GETah
GETah

Reputation: 21419

Try this findViewById(R.id.google_account).setVisibility(View.GONE); And here is the full documentation.

Upvotes: 1

Related Questions