自定义AlertDialog取消窗口

@Bind(R.id.search_btn)
Button searchBtn;
private View customDialog;
private Button controlRegulateBt;
private Button allRegulateBt;
private Button projectHxBt;
private Button searchAddressBt;
private Button dialogCancelBt;
private  AlertDialog.Builder dialog;

private Dialog dialog2;

customDialog=View.inflate(getActivity(), R.layout.search_custom_dialog, null);

private void initView() {
    controlRegulateBt= (Button) customDialog.findViewById(R.id.control_regulate_bt);
    allRegulateBt= (Button) customDialog.findViewById(R.id.all_regulate_bt);
    projectHxBt= (Button) customDialog.findViewById(R.id.project_hx_bt);
    searchAddressBt= (Button) customDialog.findViewById(R.id.search_address_bt);
    dialogCancelBt= (Button) customDialog.findViewById(R.id.search_cancel_bt);
    controlRegulateBt.setOnClickListener(this);
    allRegulateBt.setOnClickListener(this);
    projectHxBt.setOnClickListener(this);
    searchAddressBt.setOnClickListener(this);
    dialogCancelBt.setOnClickListener(this);
    searchBtn.setOnClickListener(this);

}
// 查询类型弹窗
private void showAlertDialog() {
    if (dialog==null){
        dialog = new AlertDialog.Builder(getActivity())
                .setView(customDialog);
        dialog2=dialog.create();
    }
        dialog2.show();
}
 
  
 
  
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.search_btn:
            showAlertDialog();// 查询类型弹窗
            break;
        case R.id.control_regulate_bt:
            searchControlRegulata();// 控规查询
            dialog2.dismiss();
            break;
        case R.id.all_regulate_bt:
            searchAllRegulata();  // 总规查询
            dialog2.dismiss();
            break;
        case R.id.project_hx_bt:
            searchProjectHX();  // 项目红线查询
           dialog2.dismiss();
            break;
        case R.id.search_address_bt:
            searchAddress();  // 地名地址查询
           dialog2.dismiss();
            break;
        case R.id.search_cancel_bt:
            dialog2.dismiss();
            break;
        default: break;
    }
}




你可能感兴趣的:(Dialog,AlertDialog)