MMffi Button

' Android ft

2. MST<OK>M ' *ffifi®Title)MIlXXX^ : "this is OK button"

package com.misoo.ex02;

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

public class ex02 extends Activity implements OnClickListener { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.wain); Button btn = (Button)findViewByld(R.id.button); Button btn2 = (Button)findViewById(R.id.button2); btn.setOnClickListener(this); btn2.setOnClickListener(this);

public void onClick(View arg0) { switch (arg0.getId()) { case R.id. button:

setTitle("this is OK button"); break; case R.id.button2: this.finish(); break;

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent"

android:layout_height="fill_parent"

<TextView android:id="@+id/tv"

android: lay out_width= "fill_parent"

android:layout_height="wrap_content"

android:text=""

<Button android: id=" @+id/button"

android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="OK"

<Button android: id=" @+id/button2"

android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Exit"

</LinearLayout>

AfffAA 0

0 0

Post a comment