package com.example.sum;//sum import com.example.sum.R;//sum import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView;//导入各种包 //public class MainActivity extends Activity { public class MainActivity extends Activity implements View.OnClickListener {//一个view监听点击事件 private EditText editText;//定义私有变量 private TextView textView; @Override public void onCreate(Bundle savedInstanceState) { //数据绑定函数 super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);//显示主页面 findViewById(R.id.button1).setOnClickListener(this);//找到按钮的id,设置点击监听 editText = (EditText) findViewById(R.id.editText2);//找到编辑框的id,赋值给edittext textView = (TextView) findViewById(R.id.textView1);//找到textview的id,赋值 } // public void OnMySelfClick(View v) //{ //} /* (non-Javadoc) * @see android.view.View.OnClickListener#onClick(android.view.View) */ @Override public void onClick(View v) {//点击事件函数 textView.setText(editText.getText()); // 设置textview的text为编辑框得到的数据 } } //}
http://mobile.qzone.qq.com/l?g=1357&sharekey=15b2a9456a33a3e532ab6acdf7a34d87