1 /* 2 * Copyright (C) 2013 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 com.example.android.testingfun.lesson3; 17 18 import com.example.android.testingfun.R; 19 20 import android.app.Activity; 21 import android.os.Bundle; 22 import android.view.View; 23 import android.widget.Button; 24 import android.widget.TextView; 25 26 /** 27 * Activity which shows a "click me" button. When the button is clicked, a TextView is shown below 28 * the button. 29 */ 30 public class ClickFunActivity extends Activity { 31 32 @Override 33 protected void onCreate(Bundle savedInstanceState) { 34 super.onCreate(savedInstanceState); 35 setContentView(R.layout.activity_click_fun); 36 37 final TextView infoTextView = (TextView) findViewById(R.id.info_text_view); 38 final Button clickMeButton = (Button) findViewById(R.id.launch_next_activity_button); 39 clickMeButton.setOnClickListener(new View.OnClickListener() { 40 @Override 41 public void onClick(View v) { 42 infoTextView.setVisibility(View.VISIBLE); 43 infoTextView.setText(getString(R.string.info_text)); 44 } 45 }); 46 } 47 }