Android开发 如何将EditText里面的内容显示在textView里(代码未亲测,如有不足,请留言!)...

android:layout_width="fill_parent"
android:layout_height="fill_parent"
androidrientation="vertical" >
android:id="@+id/input"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:id="@+id/output"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
主Activity程序:
package nbe.sense7.vinci.edittext;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class EditTextDemoActivity extends Activity {
private EditText editText;
private TextView textView;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

editText = (EditText)findViewById(R.id.input);
textView = (TextView)findViewById(R.id.output);

//设置EditText按键输入时的事件
editText.setOnKeyListener(new EditText.OnKeyListener(){
@Override
public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
// TODO Auto-generated method stub
textView.setText(editText.getText());
return false;
}
});
}
}

转载于:https://www.cnblogs.com/flyoung/p/4707001.html

你可能感兴趣的:(Android开发 如何将EditText里面的内容显示在textView里(代码未亲测,如有不足,请留言!)...)