Android:AlertDialog对话框

1、简单的ALertDialog:

Dialog alertDialog = new AlertDialog.Builder(this)
        .setTitle("标题")
        .setMessage("内容")
        .setIcon(R.drawable.ic_launcher).create();
        alertDialog.show();

2、带按钮的ALertDialog

public class MainActivity extends Activity {


    okListener oklistener=new okListener();
    noListener nolistener =new noListener();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.demo);
        Dialog alertDialog = new AlertDialog.Builder(this).setTitle("标题")
                .setMessage("内容").setIcon(R.drawable.ic_launcher)
                .setPositiveButton("确定", oklistener)
                .setNegativeButton("取消", nolistener)
                .create();
        alertDialog.show();
    }
    
    public class okListener implements DialogInterface.OnClickListener{

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            
        }        
    }
    
    public class noListener implements DialogInterface.OnClickListener{

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            
        }        
    }
    
    
}

 

相关文章:

Android详细的对话框AlertDialog.Builder使用方法

Android:实现退出确认对话框

posted @ 2014-10-23 17:38  tinyphp  Views(931)  Comments(0Edit  收藏  举报