• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 android.app.Activity;
20 import android.os.Bundle;
21 import android.widget.Button;
22 
23 import com.android.frameworks.coretests.R;
24 
25 /**
26  * Exercise View's ability to change their visibility: GONE, INVISIBLE and
27  * VISIBLE.
28  */
29 public class Visibility extends Activity {
30     @Override
onCreate(Bundle icicle)31     protected void onCreate(Bundle icicle) {
32         super.onCreate(icicle);
33         setContentView(R.layout.visibility);
34 
35         // Find the view whose visibility will change
36         mVictim = findViewById(R.id.victim);
37 
38         // Find our buttons
39         Button visibleButton = findViewById(R.id.vis);
40         Button invisibleButton = findViewById(R.id.invis);
41         Button goneButton = findViewById(R.id.gone);
42 
43         // Wire each button to a click listener
44         visibleButton.setOnClickListener(mVisibleListener);
45         invisibleButton.setOnClickListener(mInvisibleListener);
46         goneButton.setOnClickListener(mGoneListener);
47     }
48 
49 
50     View.OnClickListener mVisibleListener = new View.OnClickListener() {
51         public void onClick(View v) {
52             mVictim.setVisibility(View.VISIBLE);
53         }
54     };
55 
56     View.OnClickListener mInvisibleListener = new View.OnClickListener() {
57         public void onClick(View v) {
58             mVictim.setVisibility(View.INVISIBLE);
59         }
60     };
61 
62     View.OnClickListener mGoneListener = new View.OnClickListener() {
63         public void onClick(View v) {
64             mVictim.setVisibility(View.GONE);
65         }
66     };
67 
68     private View mVictim;
69 }
70