2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.widget.focus;
19 import com.android.frameworks.coretests.R;
21 import android.app.Activity;
22 import android.os.Bundle;
23 import android.widget.LinearLayout;
24 import android.widget.Button;
25 import android.view.View;
28 * Exercises cases where elements of the UI are removed (and
29 * focus should go somewhere).
31 public class FocusAfterRemoval extends Activity {
34 protected void onCreate(Bundle icicle) {
35 super.onCreate(icicle);
36 setContentView(R.layout.focus_after_removal);
38 final LinearLayout left = (LinearLayout) findViewById(R.id.leftLayout);
40 // top left makes parent layout GONE
41 Button topLeftButton = (Button) findViewById(R.id.topLeftButton);
42 topLeftButton.setOnClickListener(new View.OnClickListener() {
44 public void onClick(View v) {
45 left.setVisibility(View.GONE);
49 // bottom left makes parent layout INVISIBLE
50 // top left makes parent layout GONE
51 Button bottomLeftButton = (Button) findViewById(R.id.bottomLeftButton);
52 bottomLeftButton.setOnClickListener(new View.OnClickListener() {
54 public void onClick(View v) {
55 left.setVisibility(View.INVISIBLE);
59 // top right button makes top right button GONE
60 final Button topRightButton = (Button) findViewById(R.id.topRightButton);
61 topRightButton.setOnClickListener(new View.OnClickListener() {
63 public void onClick(View v) {
64 topRightButton.setVisibility(View.GONE);
68 // bottom right button makes bottom right button INVISIBLE
69 final Button bottomRightButton = (Button) findViewById(R.id.bottomRightButton);
70 bottomRightButton.setOnClickListener(new View.OnClickListener() {
72 public void onClick(View v) {
73 bottomRightButton.setVisibility(View.INVISIBLE);