<?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"
>

<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:background="#aa0000"
    android:layout_gravity="center"
    />

<EditText 
	android:text="EditText0111" 
	android:textStyle="italic"  
	android:layout_height="wrap_content" 
	android:layout_width="wrap_content" 
	android:layout_gravity="right" 
	android:id="@+id/edtInput">
</EditText>  
<LinearLayout 
	android:id="@+id/LinearLayout01" 
	android:layout_height="wrap_content" 
	android:layout_width="wrap_content" 
	android:layout_gravity="right"
	android:orientation="vertical"
	>
	 <!-- android:orientation="vertical"控件之间组合的顺序 -->
<Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Show1"   
      android:id="@+id/btnShow"
      >
 </Button>
 <LinearLayout 
	android:id="@+id/LinearLayout02" 
	android:layout_height="fill_parent" 
	android:layout_width="fill_parent" 
	android:layout_gravity="left"
	android:orientation="vertical"
	>  
<Button 
		android:layout_width="wrap_content" 
		android:layout_height="fill_parent" 
		android:text="Clear"  
		android:id="@+id/btnClear"
		>
 </Button>  

</LinearLayout>    
</LinearLayout>
</LinearLayout>



package hello1.java;

import android.app.Activity;
import android.os.Bundle;

import android.app.AlertDialog;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;


public class hello1 extends Activity {
    /** Called when the activity is first created. */
	Button btnShow;
	Button btnClear;
	EditText edtInput;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        btnShow = (Button)findViewById(R.id.btnShow);
        btnClear = (Button)findViewById(R.id.btnClear);
        edtInput = (EditText)findViewById(R.id.edtInput);
        btnShow.setOnClickListener(new ClickListener());
        btnClear.setOnClickListener(new ClickListener());
    }
    class ClickListener implements OnClickListener
    {
    	public void onClick(View v)
    	{
    		if(v == btnShow)
    		{
    			new AlertDialog.Builder(hello1.this)
    			.setIcon(android.R.drawable.ic_dialog_alert)
    			.setTitle("Information")
    			.setMessage(edtInput.getText())
    			.show();
    		}
    		else if(v == btnClear)
    		{
    		     edtInput.setText("Hello Android");	
    		}
    	}
    }
}