1 /* 2 * Copyright (C) 2012 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 package android.animation.cts; 17 18 import android.animation.cts.R; 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.view.View; 22 import android.view.View.OnClickListener; 23 import android.widget.Button; 24 import android.widget.LinearLayout; 25 26 public class LayoutAnimationActivity extends Activity { 27 private int mCount = 1; 28 Button mButton; 29 private Button mLastButton; 30 @Override onCreate(Bundle bundle)31 public void onCreate(Bundle bundle){ 32 super.onCreate(bundle); 33 setContentView(R.layout.animation_two); 34 mButton = (Button) findViewById(R.id.button1); 35 36 mButton.setOnClickListener(new OnClickListener(){ 37 public void onClick(View v) { 38 Button newButton = new Button(LayoutAnimationActivity.this); 39 newButton.setText("Button:" + LayoutAnimationActivity.this.mCount); 40 LinearLayout layout = (LinearLayout) findViewById(R.id.container); 41 layout.addView(newButton); 42 LayoutAnimationActivity.this.mCount++; 43 mLastButton = newButton; 44 } 45 }); 46 } 47 getLastButton()48 public Button getLastButton() { 49 return mLastButton; 50 } 51 } 52