1. Download our Official Android App: Forums for Android!

Apps Android ImageView Visibility help

Discussion in 'Android Development' started by Nicknumber, Nov 1, 2010.

  1. Nicknumber

    Nicknumber Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Nov 1, 2010

    Nov 1, 2010
    2
    0
    5
    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?
     

    Advertisement

  2. vinay1497

    vinay1497 Lurker
    Rank:
    None
    Points:
    6
    Posts:
    6
    Joined:
    Jun 8, 2010

    Jun 8, 2010
    6
    2
    6
    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
     
    Nicknumber likes this.

Share This Page

Loading...