• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android ImageView Visibility help

Nicknumber

Lurker
Nov 1, 2010
2
0
I have an ImageView object, x, loaded into my application. I want to toggle its visibility by clicking a button in the same activity. I have this code:


if(x.getVisibility() == INVISIBLE)
{
x.setVisibility(VISIBLE);
}

elseif(x.getVisibility() == VISIBLE)
{
x.setVisibility(INVISIBLE);
}


The default visibility setting is set to VISIBLE. When I click the button, the image won't vanish. Does anyone know how to fix this?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones