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使用方法

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。