package my.android.toast; import android.app.Activity; import android.os.Bundle; import android.text.Editable; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class ShowToast extends Activity { private EditText mEditText; private Button mButton; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mEditText = (EditText) findViewById(R.id.text_id); mButton = (Button) findViewById(R.id.button_id); mButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Editable Str; Str = mEditText.getText(); Toast.makeText(ShowToast.this, Str, Toast.LENGTH_SHORT).show(); mEditText.setText(""); } }); } } <?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/text_id" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/button_id" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="333" /> </LinearLayout>