Android: How to make a Spinner invisible and then

2020-08-23 01:08发布

问题:

I have the following Spinner:

Spinner spinner = (Spinner)findViewById(R.id.sp1);

and I initially make it invisible like this:

spinner.setVisibility(TRIM_MEMORY_BACKGROUND);

This does make the Spinner invisible but how to make it visible again?

Thanks in advance.

回答1:

//Hide

spinner.setVisibility(View.GONE);

//Show

spinner.setVisibility(View.VISIBLE);


回答2:

if you want to change via xml code

// HIDE

  android:visibility="invisible"

//SHOW

  android:visibility="visible"

// i am not sure about this one, it too hides, but why we have this, anyone can clear me?

  android:visibility="gone"


标签: android