@Override public void showOkMsg( String title, String msg, Button.OnClickListener onOkClicked, MsgPopupUtils.MessageLevel messageLevel) { AlertDialog.Builder builder = new Builder(this.savedContex); AlertDialog alertDialog = builder.create(); alertDialog.show(); alertDialog.getWindow().setContentView(R.layout.dialog_ok); dismissDialogs.add(alertDialog); ImageView img = ((ImageView) alertDialog.getWindow().findViewById(R.id.imgViewDialogOkTitle)); if (MsgPopupUtils.MessageLevel.FATAL == messageLevel) { img.setBackgroundResource(R.drawable.ic_fatal); } else if (MsgPopupUtils.MessageLevel.ERROR == messageLevel) { img.setBackgroundResource(R.drawable.ic_error); } else if (MsgPopupUtils.MessageLevel.WARNING == messageLevel) { img.setBackgroundResource(R.drawable.ic_warning); } else if (MsgPopupUtils.MessageLevel.ATTENTION == messageLevel) { img.setBackgroundResource(R.drawable.ic_attention); } else { img.setBackgroundResource(R.drawable.info_normal2); } ((TextView) alertDialog.getWindow().findViewById(R.id.textViewDialogOkTitle)).setText(title); ((TextView) alertDialog.getWindow().findViewById(R.id.textViewDialogOkMsg)).setText(msg); Button btnDialogOkOk = (Button) alertDialog.getWindow().findViewById(R.id.btnDialogOkOk); btnDialogOkOk.setOnClickListener(onOkClicked); }
public boolean onKey(DialogInterface dialoginterface, int i, KeyEvent keyevent) { if (i == 82 || i == 4) { if (keyevent.getAction() == 0 && keyevent.getRepeatCount() == 0) { dialoginterface = mDialog.getWindow(); if (dialoginterface != null) { dialoginterface = dialoginterface.getDecorView(); if (dialoginterface != null) { dialoginterface = dialoginterface.getKeyDispatcherState(); if (dialoginterface != null) { dialoginterface.startTracking(keyevent, this); return true; } } } } else if (keyevent.getAction() == 1 && !keyevent.isCanceled()) { Object obj = mDialog.getWindow(); if (obj != null) { obj = ((Window) (obj)).getDecorView(); if (obj != null) { obj = ((View) (obj)).getKeyDispatcherState(); if (obj != null && ((android.view.KeyEvent.DispatcherState) (obj)).isTracking(keyevent)) { mMenu.close(true); dialoginterface.dismiss(); return true; } } } } } return mMenu.performShortcut(i, keyevent, 0); }
/** 学院 */ private void showCademyDialog() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setTitle("学院") .setItems( R.array.cademys, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // user.job = which; // action_done(); curUser.setCademy(getResources().getStringArray(R.array.cademys)[which]); aq.id(R.id.et_mineinfo_cademy).text(curUser.getCademy()); } }); // builder.create().show(); WindowManager m = getWindowManager(); Display d = m.getDefaultDisplay(); AlertDialog dialog = builder.create(); dialog.show(); WindowManager.LayoutParams p = dialog.getWindow().getAttributes(); Point outSize = new Point(); d.getSize(outSize); p.height = (int) (outSize.y * 0.6); // 高度设置为屏幕的0.6 // p.width = (int) (d.getWidth() * 0.8); dialog.getWindow().setAttributes(p); dialogTitleLineColor(dialog); }
/** * 显示网络加载时的loading提示 * * @param context 上下文 * @param txt 对话框提示信息 * @return AlertDialog对话框 */ public static AlertDialog getLoadingDLG(Context context, String txt) { AlertDialog.Builder builder = new Builder(context); // 不能直接通过AlertDialog的构造函数得到AlertDialog对象,通过builder进行create AlertDialog dlg = builder.create(); // 通过AlerDialog.Builder创建AlerDialog对话框 // dlg.setCancelable(false); //设置这个对话框不能够被用户按[返回键]而取消掉 dlg.show(); // 显示AlertDialog对话框 dlg.getWindow().setContentView(R.layout.dlg_loading); TextView tv = (TextView) dlg.getWindow().findViewById(R.id.tvLoadingMsg); tv.setText(txt); // 在textview中显示对话框提示信息 return dlg; }
private void initiateMoreInfoAlert(String displayInfo, String posBtntxt) { AlertDialog popupWin = new AlertDialog.Builder(this) .setTitle("Information") .setMessage(displayInfo) .setPositiveButton(posBtntxt, null) .show(); WindowManager.LayoutParams lParams = popupWin.getWindow().getAttributes(); lParams.dimAmount = 0.2f; popupWin.getWindow().setAttributes(lParams); popupWin.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); }
private void prepareDialog() { final boolean silentModeOn = mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL; mSilentModeToggle.updateState(silentModeOn ? ToggleAction.State.On : ToggleAction.State.Off); mAirplaneModeOn.updateState(mAirplaneState); mAdapter.notifyDataSetChanged(); if (mKeyguardShowing) { mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); } else { mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG); } mDialog.setTitle(R.string.global_actions); }
public void onClick_BottomDialog(View view) { AlertDialog alertDialog = new AlertDialog.Builder(this).setMessage("在底端显示对话框").setPositiveButton("确定", null).create(); Window window = alertDialog.getWindow(); window.setGravity(Gravity.BOTTOM); alertDialog.show(); }
private void showEditDialog(final ViewHolder holder) { if (LOG) { MtkLog.v(TAG, "showEditDialog(" + holder + ")"); } if (holder == null) { return; } final LayoutInflater inflater = LayoutInflater.from(this); final View v = inflater.inflate(R.layout.bookmark_edit_dialog, null); final EditText titleView = (EditText) v.findViewById(R.id.title); final EditText dataView = (EditText) v.findViewById(R.id.data); titleView.setText(holder.mTitle); dataView.setText(holder.mData); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.edit); builder.setView(v); builder.setIcon(R.drawable.ic_menu_display_bookmark); builder.setPositiveButton( android.R.string.ok, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { mBookmark.update( holder.mId, titleView.getText().toString(), dataView.getText().toString(), 0); } }); builder.setNegativeButton(android.R.string.cancel, null); final AlertDialog dialog = builder.create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.setInverseBackgroundForced(true); dialog.show(); }
public void showAlbumDialog() { albumDialog = new AlertDialog.Builder(mContext).create(); albumDialog.setCanceledOnTouchOutside(true); View v = LayoutInflater.from(mContext).inflate(R.layout.dialog_usericon, null); albumDialog.show(); albumDialog.setContentView(v); albumDialog.getWindow().setGravity(Gravity.CENTER); TextView albumPic = (TextView) v.findViewById(R.id.album_pic); TextView cameraPic = (TextView) v.findViewById(R.id.camera_pic); albumPic.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub albumDialog.dismiss(); Date date1 = new Date(System.currentTimeMillis()); dateTime = date1.getTime() + ""; getAvataFromAlbum(); } }); cameraPic.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub albumDialog.dismiss(); Date date = new Date(System.currentTimeMillis()); dateTime = date.getTime() + ""; getAvataFromCamera(); } }); }
protected void showErrorDialog(View view, boolean cancelable) { if (getActivity().isFinishing()) return; if (mErrorDialog == null) { mErrorDialog = new AlertDialog.Builder(mContext, R.style.error_dialog).create(); mErrorDialog.setCancelable(cancelable); mErrorDialog.setCanceledOnTouchOutside(cancelable); } mErrorDialog.show(); Window window = mErrorDialog.getWindow(); window.setGravity(Gravity.CENTER | Gravity.BOTTOM); window.setContentView(view); window.setWindowAnimations(R.style.animation_error_dialog); int width = (int) (ScreenUtils.getScreenW(mContext) * 5 / 6f); WindowManager.LayoutParams wmlp = window.getAttributes(); wmlp.gravity = Gravity.CENTER | Gravity.BOTTOM; wmlp.y = 200; window.setLayout(width, ViewGroup.LayoutParams.WRAP_CONTENT); executor.schedule( new Runnable() { @Override public void run() { dismissErrorDialog(); } }, 5, TimeUnit.SECONDS); }
/** Utility function to bring up a generic "error" dialog. */ private void showErrorDialog(CharSequence msg) { Log.i(this, "Show Dialog: " + msg); dismissPendingDialogs(); mDialog = new AlertDialog.Builder(this) .setMessage(msg) .setPositiveButton( android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onDialogDismissed(); } }) .setOnCancelListener( new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { onDialogDismissed(); } }) .create(); mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); mDialog.show(); }
@SuppressWarnings("deprecation") private void ErrorDialog(int icon, int title, int content, int makesur) { final Builder builder = new AlertDialog.Builder(LoginActivity.this); // 设置对话框的图标 builder.setIcon(icon); // 设置对话框的标题 builder.setTitle(title); // 设置对话框的内容 builder.setMessage(content); // 设置对话框的"确定"按钮 builder.setNegativeButton( makesur, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub System.out.println("IRoundU"); } }); AlertDialog alertDialog = builder.create(); // 设置Dialog透明 Window window = alertDialog.getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); // 设置透明度为0.3 lp.alpha = 0.8f; window.setAttributes(lp); // Dialog后面的内容会变得模糊 window.setFlags( WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); alertDialog.show(); }
public void showDialog(String title, String message, String str_Positive, String str_Negative) { AlertDialog.Builder builder = new Builder(ShowEventContent.this); builder.setTitle(title); builder.setMessage(message); builder.setPositiveButton( str_Positive, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { deleteCJXX(bhq_XHSJ.getSJID()); dialog.dismiss(); } }); builder.setNegativeButton( str_Negative, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialog.dismiss(); } }); dialog = builder.create(); dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); dialog.show(); }
public void showfenxdialog() { LayoutInflater inflate = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflate.inflate(R.layout.touzhu_succe, null); final AlertDialog dialog = new AlertDialog.Builder(getParent()).create(); ImageView image = (ImageView) view.findViewById(R.id.touzhu_succe_img); Button ok = (Button) view.findViewById(R.id.touzhu_succe_button_sure); Button share = (Button) view.findViewById(R.id.touzhu_succe_button_share); image.setImageResource(R.drawable.succee); ok.setBackgroundResource(R.drawable.loginselecter); share.setBackgroundResource(R.drawable.loginselecter); ok.setOnClickListener( new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub dialog.cancel(); ZiXuanTouZhu.this.finish(); } }); share.setOnClickListener( new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub dialog.cancel(); ZiXuanTouZhu.this.finish(); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, "分享给朋友"); intent.putExtra(Intent.EXTRA_TEXT, "我刚刚使用如意彩手机客户端购买了一张彩票:" + "快来参与吧!官网www.ruyicai.com"); startActivity(Intent.createChooser(intent, "请选择分享方式")); } }); dialog.show(); dialog.getWindow().setContentView(view); }
public void show() { // TODO Auto-generated method stub alertDialog.setView( ((Activity) (context)).getLayoutInflater().inflate(R.layout.recharge_dialog, null)); alertDialog.show(); alertDialog.getWindow().setContentView(view); }
public void show(IBinder ibinder) { Object obj = mMenu; android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(((MenuBuilder) (obj)).getContext()); mPresenter = new ListMenuPresenter( android.support.v7.appcompat.R.layout.abc_list_menu_item_layout, android.support.v7.appcompat.R.style.Theme_AppCompat_CompactMenu_Dialog); mPresenter.setCallback(this); mMenu.addMenuPresenter(mPresenter); builder.setAdapter(mPresenter.getAdapter(), this); View view = ((MenuBuilder) (obj)).getHeaderView(); if (view != null) { builder.setCustomTitle(view); } else { builder .setIcon(((MenuBuilder) (obj)).getHeaderIcon()) .setTitle(((MenuBuilder) (obj)).getHeaderTitle()); } builder.setOnKeyListener(this); mDialog = builder.create(); mDialog.setOnDismissListener(this); obj = mDialog.getWindow().getAttributes(); obj.type = 1003; if (ibinder != null) { obj.token = ibinder; } obj.flags = ((android.view.WindowManager.LayoutParams) (obj)).flags | 0x20000; mDialog.show(); }
public void showIssue(final String issue) { LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflate.inflate(R.layout.touzhu_succe, null); final AlertDialog dialog = new AlertDialog.Builder(context).create(); TextView textContent = (TextView) view.findViewById(R.id.touzhu_succe_text); Button ok = (Button) view.findViewById(R.id.touzhu_succe_button_sure); Button cancel = (Button) view.findViewById(R.id.touzhu_succe_button_share); ok.setBackgroundResource(R.drawable.loginselecter); cancel.setBackgroundResource(R.drawable.loginselecter); ok.setText(context.getString(R.string.dialog_issue_text_ok)); cancel.setText(context.getString(R.string.dialog_issue_text_cancel)); textContent.setText(context.getString(R.string.dialog_issue_text_content) + issue + "期。"); ok.setOnClickListener( new OnClickListener() { public void onClick(View v) { dialog.cancel(); touzhuIssue(issue); } }); cancel.setOnClickListener( new OnClickListener() { public void onClick(View v) { dialog.cancel(); finish(); } }); dialog.show(); dialog.getWindow().setContentView(view); }
private AlertDialog cancleTrackDialog(final String id) { LayoutInflater factory = LayoutInflater.from(this); /*中奖查询的查看详情使用余额查询的布局*/ View view = factory.inflate(R.layout.usercenter_balancequery, null); final AlertDialog dialog = new AlertDialog.Builder(this).create(); TextView title = (TextView) view.findViewById(R.id.usercenter_balancequery_title); TextView remind = (TextView) view.findViewById(R.id.usercenter_remind_text); remind.setVisibility(TextView.GONE); title.setText(R.string.cancel_add_num); TextView detailTextView = (TextView) view.findViewById(R.id.balanceinfo); detailTextView.setTextSize(18); detailTextView.setText(R.string.usercenter_cancleTrackRemind); Button cancleLook = (Button) view.findViewById(R.id.usercenter_balancequery_back); cancleLook.setOnClickListener( new OnClickListener() { public void onClick(View v) { dialog.cancel(); } }); Button okBtn = (Button) view.findViewById(R.id.usercenter_balancequery_ok); okBtn.setVisibility(Button.VISIBLE); okBtn.setOnClickListener( new OnClickListener() { public void onClick(View v) { dialog.cancel(); cancleTrackNet(id); } }); dialog.show(); dialog.getWindow().setContentView(view); return dialog; }
/** * 打开单选框 * * @param context 上下文 */ public static AlertDialog showWaiting(Context context) { final AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.show(); Window window = alertDialog.getWindow(); WindowManager.LayoutParams layoutParams = window.getAttributes(); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; window.setGravity(Gravity.CENTER); window.setAttributes(layoutParams); window.setContentView(R.layout.dialog_waiting); ViewGroup background = (ViewGroup) window.findViewById(R.id.waiting_layout_background); background.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // alertDialog.cancel(); } }); ImageView icon = (ImageView) window.findViewById(R.id.waiting_image_icon); final RotateAnimation animation = new RotateAnimation( 0f, 720f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(2000); animation.setRepeatCount(Animation.INFINITE); icon.startAnimation(animation); return alertDialog; }
public void showfenxdialog(String messagestr) { LayoutInflater inflate = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflate.inflate(R.layout.touzhu_succe, null); final AlertDialog dialog = new AlertDialog.Builder(this).create(); ImageView image = (ImageView) view.findViewById(R.id.touzhu_succe_img); Button ok = (Button) view.findViewById(R.id.touzhu_succe_button_sure); Button share = (Button) view.findViewById(R.id.touzhu_succe_button_share); TextView message = (TextView) view.findViewById(R.id.touzhu_succe_text); message.setText(messagestr); image.setImageResource(R.drawable.succee); ok.setBackgroundResource(R.drawable.loginselecter); share.setBackgroundResource(R.drawable.loginselecter); ok.setOnClickListener( new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub dialog.cancel(); JoinStartActivity.this.finish(); } }); share.setOnClickListener( new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub dialog.cancel(); Intent intent = new Intent(JoinStartActivity.this, JoinStarShare.class); JoinStartActivity.this.startActivity(intent); JoinStartActivity.this.finish(); } }); dialog.show(); dialog.getWindow().setContentView(view); }
public static void dialogColor(AlertDialog dialog) { try { Resources resources = dialog.getContext().getResources(); int color = resources.getColor(R.color.orange); // your color here int alertTitleId = resources.getIdentifier("alertTitle", "id", "android"); TextView alertTitle = (TextView) dialog.getWindow().getDecorView().findViewById(alertTitleId); alertTitle.setTextColor(color); // change title text color int titleDividerId = resources.getIdentifier("titleDivider", "id", "android"); View titleDivider = dialog.getWindow().getDecorView().findViewById(titleDividerId); titleDivider.setBackgroundColor(color); // change divider color } catch (Exception ex) { ex.printStackTrace(); } }
@Override public boolean onLongClick(View v) { final SingleGameItem gameItem = (SingleGameItem) v.getTag(); if (gameItem != null) { final AlertDialog dialog = new AlertDialog.Builder(activity).create(); dialog.show(); Window window = dialog.getWindow(); window.setContentView(R.layout.alert_maingame); Button startBtn = (Button) window.findViewById(R.id.startBtn); Button detailBtn = (Button) window.findViewById(R.id.DetailBtn); startBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); startGame(gameItem); } }); detailBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); Intent intent = new Intent(activity, DetailPageActivity.class); intent.putExtra("gameItem", gameItem); activity.startActivity(intent); } }); } return false; }
private void showContactInviteDialog(final Contact contact) { final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext()); View view = getActivity() .getLayoutInflater() .inflate(R.layout.dialog_invite_contact, (ViewGroup) getView().getRootView(), false); View rootView = view.findViewById(R.id.dialog_root_view); TextView dialogTitle = (TextView) view.findViewById(R.id.dialog_title); dialogTitle.setTypeface(TypefaceUtil.PROXIMA_NOVA_BOLD); dialogMessage = (EditText) view.findViewById(R.id.contact_invite_message); dialogMessage.setTypeface(TypefaceUtil.PROXIMA_NOVA); TextView dialogCancel = (TextView) view.findViewById(R.id.invite_cancel); dialogCancel.setTypeface(TypefaceUtil.PROXIMA_NOVA_BOLD); TextView dialogSend = (TextView) view.findViewById(R.id.invite_send); dialogSend.setTypeface(TypefaceUtil.PROXIMA_NOVA_BOLD); dialogBuilder.setView(view); dialog = dialogBuilder.create(); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialogCancel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialogSend.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { sendSMSMessage(contact); } }); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; dialog.show(); dialog.getWindow().setLayout(1000, 1000); }
@Override protected Dialog onCreateDialog(int id) { switch (id) { case PASSWORD_DIALOG: AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog passwordDialog = builder.create(); passwordDialog.setTitle(getString(R.string.enter_admin_password)); final EditText input = new EditText(this); input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); input.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordDialog.setView(input, 20, 10, 20, 10); passwordDialog.setButton( AlertDialog.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); String pw = mAdminPreferences.getString(AdminPreferencesActivity.KEY_ADMIN_PW, ""); if (pw.compareTo(value) == 0) { Intent i = new Intent(getApplicationContext(), AdminPreferencesActivity.class); startActivity(i); input.setText(""); passwordDialog.dismiss(); } else { Toast.makeText( MainMenuActivity.this, getString(R.string.admin_password_incorrect), Toast.LENGTH_SHORT) .show(); MyStatus.getInstance() .getActivityLogger() .logAction(this, "adminPasswordDialog", "PASSWORD_INCORRECT"); } } }); passwordDialog.setButton( AlertDialog.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { MyStatus.getInstance() .getActivityLogger() .logAction(this, "adminPasswordDialog", "cancel"); input.setText(""); return; } }); passwordDialog .getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); return passwordDialog; } return null; }
/** * @param activityContext * @param btnNameResId String resource id for button name */ public static void showErrorDialog(Context activityContext, String msg, int btnNameResId) { AlertDialog.Builder builder = new AlertDialog.Builder(activityContext); builder.setTitle("Error").setMessage(msg).setPositiveButton(btnNameResId, null); AlertDialog alert = builder.create(); alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); if (!((Activity) activityContext).isFinishing()) { alert.show(); } }
/** 选择头像时弹出的对话框 */ private void showDialog() { final AlertDialog potraidDlg = new AlertDialog.Builder(super.getActivity()).create(); potraidDlg.show(); Window win = potraidDlg.getWindow(); win.setContentView(R.layout.dialog_show_photo); View viewTop = win.findViewById(R.id.view_top_dialog_sethead); View viewBottom = win.findViewById(R.id.view_bottom_dialog_sethead); RadioButton photo = (RadioButton) win.findViewById(R.id.rb_photo_dialog_sethead); RadioButton pic = (RadioButton) win.findViewById(R.id.rb_pic_dialog_sethead); RadioButton bind = (RadioButton) win.findViewById(R.id.rb_bind_dialog_sethead); // 点击dialog外部,关闭dialog viewTop.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub potraidDlg.dismiss(); } }); viewBottom.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub potraidDlg.dismiss(); } }); // 调用相机 photo.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub Intent intentPhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intentPhoto.putExtra( MediaStore.EXTRA_OUTPUT, Uri.fromFile( new File(Environment.getExternalStorageDirectory(), "/user_head.png"))); startActivityForResult(intentPhoto, 22); potraidDlg.dismiss(); } }); // 调用相片 pic.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub Intent intentPic = new Intent(Intent.ACTION_PICK, null); intentPic.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); startActivityForResult(intentPic, 11); potraidDlg.dismiss(); } }); }
public AlertDialog lookDetailDialog(final WinPrizeQueryInfo info) { LayoutInflater factory = LayoutInflater.from(this); /* 中奖查询的查看详情使用余额查询的布局 */ View view = factory.inflate(R.layout.win_detail, null); final AlertDialog dialog = new AlertDialog.Builder(this).create(); TextView lotkind = (TextView) view.findViewById(R.id.gift_detail_text_lotno); TextView batchcode = (TextView) view.findViewById(R.id.gift_detail_text_batchcode); TextView dingdanno = (TextView) view.findViewById(R.id.gift_detail_text_dingdan); TextView beishu = (TextView) view.findViewById(R.id.gift_detail_text_beishu); TextView zhushu = (TextView) view.findViewById(R.id.gift_detail_text_zhushu); TextView atm = (TextView) view.findViewById(R.id.gift_detail_text_atm); TextView statetext = (TextView) view.findViewById(R.id.gift_detail_text_state); TextView bettime = (TextView) view.findViewById(R.id.gift_detail_tex_gifttime); TextView content = (TextView) view.findViewById(R.id.gift_detail_text_content); TextView person = (TextView) view.findViewById(R.id.gift_detail_text_person); TextView kaijianghao = (TextView) view.findViewById(R.id.gift_detail_text_kaijianghao); TextView atmz = (TextView) view.findViewById(R.id.gift_detail_text_atmzhong); TextView cashtime = (TextView) view.findViewById(R.id.gift_detail_tex_time); final String lotno = info.getLotNo(); lotkind.append(info.getLotName()); if (lotno.equals("J00001") || lotno.equals("J00002") || lotno.equals("J00003") || lotno.equals("J00004") || lotno.equals(Constants.LOTNO_JCLQ) || lotno.equals(Constants.LOTNO_JCLQ_DXF) || lotno.equals(Constants.LOTNO_JCLQ_RF) || lotno.equals(Constants.LOTNO_JCLQ_SFC)) { batchcode.setVisibility(View.GONE); } else { batchcode.setVisibility(TextView.VISIBLE); batchcode.append(info.getBatchCode()); } dingdanno.append(info.getOrderId()); beishu.append(info.getLotMulti()); zhushu.append(info.getBetNum()); final String FormatAmount = PublicMethod.toYuan(info.getAmount()); atm.append(FormatAmount + "元"); atmz.append(PublicMethod.toYuan(info.getWinAmount()) + "元"); cashtime.append(info.getCashTime()); person.setVisibility(View.GONE); statetext.setVisibility(View.GONE); kaijianghao.setVisibility(View.GONE); bettime.append(info.getSellTime()); content.setText(Html.fromHtml("方案内容:<br>" + info.getBetCodeHtml())); Button cancleLook = (Button) view.findViewById(R.id.gift_detail_img_cannle); cancleLook.setOnClickListener( new OnClickListener() { public void onClick(View v) { dialog.cancel(); } }); dialog.show(); dialog.getWindow().setContentView(view); return dialog; }
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mPackageName = getCallingPackage(); IBinder b = ServiceManager.getService(MEDIA_PROJECTION_SERVICE); mService = IMediaProjectionManager.Stub.asInterface(b); if (mPackageName == null) { finish(); return; } PackageManager packageManager = getPackageManager(); ApplicationInfo aInfo; try { aInfo = packageManager.getApplicationInfo(mPackageName, 0); mUid = aInfo.uid; } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "unable to look up package name", e); finish(); return; } try { if (mService.hasProjectionPermission(mUid, mPackageName)) { setResult( RESULT_OK, getMediaProjectionIntent(mUid, mPackageName, false /*permanentGrant*/)); finish(); return; } } catch (RemoteException e) { Log.e(TAG, "Error checking projection permissions", e); finish(); return; } String appName = aInfo.loadLabel(packageManager).toString(); mDialog = new AlertDialog.Builder(this) .setIcon(aInfo.loadIcon(packageManager)) .setMessage(getString(R.string.media_projection_dialog_text, appName)) .setPositiveButton(R.string.media_projection_action_text, this) .setNegativeButton(android.R.string.cancel, this) .setView(R.layout.remember_permission_checkbox) .setOnCancelListener(this) .create(); mDialog.create(); ((CheckBox) mDialog.findViewById(R.id.remember)).setOnCheckedChangeListener(this); mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mDialog.show(); }
/** * 打开单选框 * * @param context 上下文 * @param parameters 参数列表 */ public static void showSelector( Context context, final IEventable<Integer> callback, String... parameters) { final AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.show(); Window window = alertDialog.getWindow(); WindowManager.LayoutParams layoutParams = window.getAttributes(); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; window.setGravity(Gravity.BOTTOM); window.setAttributes(layoutParams); LinearLayout contentLayout = new LinearLayout(context); LinearLayout.LayoutParams contentLayoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); contentLayout.setGravity(Gravity.BOTTOM); contentLayout.setOrientation(LinearLayout.VERTICAL); contentLayout.setBackgroundColor(context.getResources().getColor(R.color.grey_bg)); boolean sentry = false; int position = -1; for (int i = 0; i < parameters.length; i++) { String parameter = parameters[i]; if (Text.isBlank(parameter)) { sentry = true; continue; } position++; TextView textView = new TextView(context); textView.setText(parameter); textView.setTag(position); textView.setGravity(Gravity.CENTER); textView.setTextColor(context.getResources().getColor(R.color.grey_text)); textView.setTextSize(18); textView.setBackgroundColor(Color.WHITE); textView.setHeight(GraphicsHelper.dip2px(context, 40)); LinearLayout.LayoutParams textLayoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); if (sentry) { textLayoutParams.topMargin = GraphicsHelper.dip2px(context, 2); } else { textLayoutParams.topMargin = GraphicsHelper.dip2px(context, 1); } contentLayout.addView(textView, textLayoutParams); textView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { callback.on((Integer) v.getTag()); alertDialog.cancel(); } }); } window.setContentView(contentLayout, contentLayoutParams); }
/** {@inheritDoc} */ @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { final EditText editText = new EditText(getContext()); editText.setText(mText); //noinspection deprecation editText.setTextColor(getResources().getColor(R.color.textColor)); editText.selectAll(); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder .setTitle(mTitle) .setMessage(mMessage) .setCancelable(true) .setView(editText) .setPositiveButton( android.R.string.ok, new DialogInterface.OnClickListener() { /** * Handler for click event * * @param dialog Dialog * @param whichButton Selected option */ @Override public void onClick(DialogInterface dialog, int whichButton) { onTextEntered(editText.getText().toString()); dialog.dismiss(); } }) .setNegativeButton( android.R.string.cancel, new DialogInterface.OnClickListener() { /** * Handler for click event * * @param dialog Dialog * @param whichButton Selected option */ @Override public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); return dialog; }