final AlertDialog dialog = ...; editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } });
// create dialog final AlertDialog dialog = ...; // request keyboard dialog.getWindow().setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
AlertDialog alertToShow = alert.create(); alertToShow.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); alertToShow.show();
AlertDialog.Builder b = new AlertDialog.Builder(this);//.... AlertDialog dialog = b.create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.show();
AlertDialog.Builder builder = new AlertDialog.Builder(); AlertDialog dialog; builder.set... dialog = builder.create(); dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.show();
//show the dialog first AlertDialog dialog = new AlertDialog.Builder(this) .setTitle("Test Dialog") .setMessage("This should expand to the full width") .show(); //Grab the window of the dialog, and change the width WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); Window window = dialog.getWindow(); lp.copyFrom(window.getAttributes()); //This makes the dialog take up the full width lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; window.setAttributes(lp);
protected void rotateSettingsDialog(int degrees) { if (settingsDialog != null && settingsDialog.isShowing() && Build.VERSION.SDK_INT > 10) { ViewGroup dialogView = (ViewGroup) settingsDialog.getWindow().getDecorView(); for (int i = 0; i < dialogView.getChildCount(); i++) { dialogView.getChildAt(i).setRotation(degrees); } } }
public void showNoticeDialog(String alertInfo, final Thread thread) { AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setTitle(noticeTitle); builder.setMessage(alertInfo); builder.setPositiveButton(positiveButtonString, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); showDownloadDialog(); thread.start(); } }); builder.setNegativeButton(negativeButtonString, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog noticeDialog = builder.create(); // noticeDialog.setContentView(v); WindowManager.LayoutParams lp = noticeDialog.getWindow().getAttributes(); lp.height = 200; noticeDialog.getWindow().setAttributes(lp); noticeDialog.setCancelable(false); noticeDialog.show(); }
private void getCustomFood() { String title = getActivity().getResources().getString(R.string.enter_meal); final EditText input = new EditText(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(title) .setCancelable(true) .setView(input) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { foodChoice = input.getText().toString(); setFoodText(); notifyDataChanged(); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); AlertDialog dialog = builder.create(); // always popup the keyboard when the alert dialog shows dialog.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.show(); }
Button submit = (Button) findViewById(R.id.submitButton); submit.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(Application1GoodExample.this); builder.setMessage("Your form has been successfully submitted"); builder.setNegativeButton("Exit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // this will solve your error AlertDialog alert = builder.create(); alert.show(); alert.getWindow().getAttributes(); TextView textView = (TextView) alert.findViewById(android.R.id.message); textView.setTextSize(40); Button btn1 = alert.getButton(DialogInterface.BUTTON_NEGATIVE); btn1.setTextSize(16); } });
public void onDialog(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setTitle("Test animation"); builder.setMessage("Animator for dialog"); builder.setPositiveButton("ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.show(); Window window = dialog.getWindow(); assert window != null; ViewAnimator.animate(view, window.getDecorView()) .slideBottomIn() .interpolator(new DecelerateInterpolator()) .start(); }
settingsDialog.show(); WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.copyFrom(settingsDialog.getWindow().getAttributes()); layoutParams.width = Utils.convertDipToPixels(context, 350); layoutParams.height = Utils.convertDipToPixels(context, 350); settingsDialog.getWindow().setAttributes(layoutParams);
AlertDialog d = builder.create(); d.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); d.show();
AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle("Test dialog"); builder.setIcon(R.drawable.icon); builder.setMessage("Content"); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //Do something dialog.dismiss(); } }); builder.setNegativeButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); alert.show();
public static void brandAlertDialog(AlertDialog dialog) { try { Resources resources = dialog.getContext().getResources(); int color = resources.getColor(...); // 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(); } }
protected void rotateSettingsDialog(int degrees) { if (mSettingsDialog != null && mSettingsDialog.isShowing() && Build.VERSION.SDK_INT > 10) { ViewGroup dialogView = (ViewGroup) mSettingsDialog.getWindow().getDecorView(); for (int i = 0; i < dialogView.getChildCount(); i++) { dialogView.getChildAt(i).setRotation(degrees); } } }
alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);