WEB开发网
开发学院手机开发Android 开发 Android View添加 Listener 小技巧示例 阅读

Android View添加 Listener 小技巧示例

 2010-06-19 17:48:00 来源:WEB开发网   
核心提示:import android.view.View;public class TestOnClickListener extends Activity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstan

import android.view.View;

public class TestOnClickListener extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

}

public void myClickHandler(View target){

switch (target.getId()) {

case R.id.Button01:

setTitle("myClickHandler01");

break;

case R.id.Button02:

setTitle("myClickHandler02");

break;

}

}

}

package com.ray.test;

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

public class TestOnClickListener extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

}

public void myClickHandler(View target){

switch (target.getId()) {

case R.id.Button01:

setTitle("myClickHandler01");

break;

case R.id.Button02:

setTitle("myClickHandler02");

break;

}

}

}

参考文章:《UI framework changes in Android 1.6》(需翻墙)

上一页  1 2 3 4 

Tags:Android View 添加

编辑录入:coldstar [复制链接] [打 印]
赞助商链接