今天练习一下控件的键盘事件!也就是onKey事件!
练习题目:
在编辑框中输入、在文本框中实时的显示!
代码:
public class LinkifyActivity extends Activity {
TextView url;
EditText urlTwo;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.linkify);
url = (TextView)findViewById(R.id.textOne);
urlTwo = (EditText)findViewById(R.id.editOne);
urlTwo.setOnKeyListener(new EditText.OnKeyListener(){
public boolean onKey(View v, int keyCode, KeyEvent event) {
url.setText(urlTwo.getText().toString());
return false;
}
});
}
}