android 對話框dialog使用

參考博文:http://www.cnblogs.com/menlsh/archive/2013/03/05/2945287.html html

http://blog.csdn.net/liang5630/article/details/44098899 java


貼幾個本身寫過的例子就會懂了。。 ide

new AlertDialog.Builder(task_read.this)
                            .setPositiveButton("肯定",new DialogInterface.OnClickListener(){
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    db.delete("my_table","_id="+String.valueOf(id),null);

                                    Intent  intent1=new Intent(task_read.this,MainActivity.class);
                                    startActivity(intent1);
                                }
                            }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    }).setTitle("是否要刪除").create().show();



ad = new AlertDialog.Builder(add_task.this)
                        .setTitle("設置重複週期")
                        .setView(repeat_layout)
                        .setPositiveButton("設置", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                cycleTime="每"+sp1.getSelectedItem().toString()+sp2.getSelectedItem().toString();
                                et4.setText(cycleTime);
                                ad.dismiss();

                            }
                        })
                        .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {

                            }
                        }).show();
setView是加載自定義佈局界面
相關文章
相關標籤/搜索