標籤:content alert 提示框 bundle ble stat close protect 建立
Toast資訊氣球
1 Button bt1=(Button)findViewById(R.id.Tbt01); 2 Button bt2=(Button)findViewById(R.id.Tbt02); 3 bt1.setOnClickListener(new OnClickListener() { 4 public void onClick(View v) { 5 Toast.makeText(Toast0.this, "按鈕1短提示", 6 Toast.LENGTH_SHORT).show(); 7 } 8 }); 9 bt2.setOnClickListener(new OnClickListener() {10 public void onClick(View v) {11 Toast.makeText(Toast0.this, "按鈕2長提示",12 Toast.LENGTH_LONG).show();13 }14 });資訊氣球
Dialog(對話方塊)、AlertDialog(警告框)
1 protected void onCreate(Bundle savedInstanceState) { 2 super.onCreate(savedInstanceState); 3 setContentView(R.layout.dialog); 4 bt = (Button) findViewById(R.id.Dbt); 5 bt.setOnClickListener(new OnClickListener() { 6 public void onClick(View v) { 7 Dialog dialog=new AlertDialog.Builder(Dialog0.this) 8 .setTitle("警告") //設定標題 9 .setMessage("股市有風險,投資需謹慎") //顯示資訊10 .setIcon(R.drawable.go) //設定顯示的圖片11 .create(); //建立Dialog12 dialog.show(); //顯示對話方塊13 }14 });警告框
進階控制項【安卓5】——資訊氣球、對話方塊