<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="@+id/d1"
android:text="输入信息"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/d2"
android:text="显示信息"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:id="@+id/d3"
android:text="输入的信息是:"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
package com.sg;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class d extends Activity {
private EditText e=null; private Button b=null; private TextView t=null;
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.d); e=(EditText) super.findViewById(R.id.d1); b=(Button) super.findViewById(R.id.d2); t=(TextView) super.findViewById(R.id.d3); b.setOnClickListener(new OnClickListener(){ public void OnClick(View v){ String x=e.getText().toString(); MyClickDemo.this.b.setTest("输入的内容是:"+x); } } ); } }