public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        // 通过 Tost.makeText().show() 来实现提示性的通知效果
        // 短时间的提示性通知的 Demo
        Button btn1 = (Button) this.findViewById(R.id.btn1);
        btn1.setText("短时间提示");
        btn1.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(Main.this, "我是短时间提示", Toast.LENGTH_SHORT).show();
            }
        });
        // 长时间的提示性通知的 Demo
        Button btn2 = (Button) this.findViewById(R.id.btn2);
        btn2.setText("长时间提示");
        btn2.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(Main.this, "我是长时间提示", Toast.LENGTH_LONG).show();
            }
        });
        // 以一个 View 作为提示性通知的 Demo
        Button btn3 = (Button) this.findViewById(R.id.btn3);
        btn3.setText("以一个 View 做提示");
        btn3.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                View view = inflateView(R.layout.view);
                TextView txtMsg = (TextView) view.findViewById(R.id.txtMsg);
                txtMsg.setText("提示内容");
                Toast toast = new Toast(Main.this);
                toast.setView(view);
                toast.setDuration(Toast.LENGTH_LONG);
                toast.show();
            }
        });
  }
}