package com.test.android;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class Test extends Activity {
private TextView t1;
private Button btn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
t1 = new TextView(this);
t1 = (TextView)findViewById(R.id.text1);
t1.setText(" Hello ");
addBtnListener();
}
private void addBtnListener() {
btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
t1.setText(" My name is Android ");
}
});
}
}
No comments:
Post a Comment