1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.view; 18 19 import com.android.frameworks.coretests.R; 20 21 import android.os.Bundle; 22 import android.widget.Button; 23 import android.view.View; 24 import android.app.Activity; 25 26 /** 27 * Exercise View's ability to change their visibility: GONE, INVISIBLE and 28 * VISIBLE. 29 */ 30 public class Visibility extends Activity { 31 @Override 32 protected void onCreate(Bundle icicle) { 33 super.onCreate(icicle); 34 setContentView(R.layout.visibility); 35 36 // Find the view whose visibility will change 37 mVictim = findViewById(R.id.victim); 38 39 // Find our buttons 40 Button visibleButton = findViewById(R.id.vis); 41 Button invisibleButton = findViewById(R.id.invis); 42 Button goneButton = findViewById(R.id.gone); 43 44 // Wire each button to a click listener 45 visibleButton.setOnClickListener(mVisibleListener); 46 invisibleButton.setOnClickListener(mInvisibleListener); 47 goneButton.setOnClickListener(mGoneListener); 48 } 49 50 51 View.OnClickListener mVisibleListener = new View.OnClickListener() { 52 public void onClick(View v) { 53 mVictim.setVisibility(View.VISIBLE); 54 } 55 }; 56 57 View.OnClickListener mInvisibleListener = new View.OnClickListener() { 58 public void onClick(View v) { 59 mVictim.setVisibility(View.INVISIBLE); 60 } 61 }; 62 63 View.OnClickListener mGoneListener = new View.OnClickListener() { 64 public void onClick(View v) { 65 mVictim.setVisibility(View.GONE); 66 } 67 }; 68 69 private View mVictim; 70 } 71