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.widget.focus; 18 19 import com.android.frameworks.coretests.R; 20 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; 26 27 /** 28 * Exercises cases where elements of the UI are removed (and 29 * focus should go somewhere). 30 */ 31 public class FocusAfterRemoval extends Activity { 32 33 onCreate(Bundle icicle)34 protected void onCreate(Bundle icicle) { 35 super.onCreate(icicle); 36 setContentView(R.layout.focus_after_removal); 37 38 final LinearLayout left = (LinearLayout) findViewById(R.id.leftLayout); 39 40 // top left makes parent layout GONE 41 Button topLeftButton = (Button) findViewById(R.id.topLeftButton); 42 topLeftButton.setOnClickListener(new View.OnClickListener() { 43 44 public void onClick(View v) { 45 left.setVisibility(View.GONE); 46 } 47 }); 48 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() { 53 54 public void onClick(View v) { 55 left.setVisibility(View.INVISIBLE); 56 } 57 }); 58 59 // top right button makes top right button GONE 60 final Button topRightButton = (Button) findViewById(R.id.topRightButton); 61 topRightButton.setOnClickListener(new View.OnClickListener() { 62 63 public void onClick(View v) { 64 topRightButton.setVisibility(View.GONE); 65 } 66 }); 67 68 // bottom right button makes bottom right button INVISIBLE 69 final Button bottomRightButton = (Button) findViewById(R.id.bottomRightButton); 70 bottomRightButton.setOnClickListener(new View.OnClickListener() { 71 72 public void onClick(View v) { 73 bottomRightButton.setVisibility(View.INVISIBLE); 74 } 75 }); 76 77 } 78 } 79