Android examples for User Interface:View Hide Show
Toggle a view's visibility between VISIBLE and GONE.
//package com.java2s; import android.support.annotation.NonNull; import android.view.View; public class Main { /**//from w w w. j ava2 s . c om * Toggle a view's visibility between VISIBLE and GONE. If input view's visibility is INVISIBLE, * the method will toggle it to VISIBLE * * @param view the view that will have its visibility toggled */ public static void toggleVisibility(@NonNull View view) { final int currentVisibility = view.getVisibility(); view.setVisibility(currentVisibility == View.VISIBLE ? View.GONE : View.VISIBLE); } }