Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

New Forums: Nexus 6 | Nexus Player | Nexus 9
test: Reply
 
LinkBack Thread Tools
Old November 1st, 2010, 09:29 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Nov 2010
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default Android ImageView Visibility help

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?

Advertisements
Nicknumber is offline  
Reply With Quote
sponsored links
Old December 7th, 2010, 04:38 AM   #2 (permalink)
New Member
 
Join Date: Jun 2010
Posts: 6
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hello,

In your Layout xml file you can give the image visibility with "android:visibility="invisible" "

And in your .java file

x.setVisibility(1); // it will be visible if set to 0 invisible


Good luck

Thanks
Vinay Guntaka
vinay1497 is offline  
Reply With Quote
The Following User Says Thank You to vinay1497 For This Useful Post:
Nicknumber (March 28th, 2011)
Reply
Tags
activity, display., refresh, reload, restart, sreen


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 03:34 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.