1#
安卓Developer QQ群273843464欢迎您的加入~~

EditText控件的文字自动输出到TextView例子(例子可去群共享下载)
  1. private TextView    m_TextView;

  2.     private EditText    m_EditText;



  3.     /** Called when the activity is first created. */

  4.     @Override

  5.     public void onCreate(Bundle savedInstanceState)

  6.     {

  7.         super.onCreate(savedInstanceState);

  8.         setContentView(R.layout.main);



  9.         m_TextView = (TextView) findViewById(R.id.TextView01);

  10.         m_EditText = (EditText) findViewById(R.id.EditText01);



  11.         m_TextView.setTextSize(20);



  12.         m_EditText.setHint("这是一个没有输入时的文字");

  13.         



  14.         m_EditText.setOnKeyListener(new EditText.OnKeyListener() {

  15.             @Override

  16.             public boolean onKey(View arg0, int arg1, KeyEvent arg2)

  17.             {

  18.                 // TODO Auto-generated method stub

  19.         

  20.                 m_TextView.setText("aaa" + m_EditText.getText().toString());

  21.                 return false;

  22.             }

  23.         });

  24.     }

复制代码
萨顶顶

布局:
参看这里:
http://blog.cfxixi.com/post/2012/10/17/%E5%AE%89%E5%8D%93%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E7%9A%84EditText%E4%BE%8B%E5%AD%90.aspx