android.app.AlertDialog.getWindow()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(214)

本文整理了Java中android.app.AlertDialog.getWindow()方法的一些代码示例,展示了AlertDialog.getWindow()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AlertDialog.getWindow()方法的具体详情如下:
包路径:android.app.AlertDialog
类名称:AlertDialog
方法名:getWindow

AlertDialog.getWindow介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

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);
    }
  }
});

代码示例来源:origin: stackoverflow.com

// create dialog
final AlertDialog dialog = ...; 

// request keyboard   
dialog.getWindow().setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

代码示例来源:origin: stackoverflow.com

AlertDialog alertToShow = alert.create();
alertToShow.getWindow().setSoftInputMode(
  WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
alertToShow.show();

代码示例来源:origin: stackoverflow.com

AlertDialog.Builder b = new AlertDialog.Builder(this);//....
AlertDialog dialog = b.create();

dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

dialog.show();

代码示例来源:origin: stackoverflow.com

AlertDialog.Builder builder = new AlertDialog.Builder();
AlertDialog dialog;

builder.set...

dialog = builder.create();
dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
dialog.show();

代码示例来源:origin: stackoverflow.com

//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);

代码示例来源:origin: florent37/CameraFragment

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);
    }
  }
}

代码示例来源:origin: cymcsg/UltimateAndroid

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();
}

代码示例来源:origin: facebook/facebook-android-sdk

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();
}

代码示例来源:origin: stackoverflow.com

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);
  }
});

代码示例来源:origin: florent37/ViewAnimator

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();
}

代码示例来源:origin: florent37/CameraFragment

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);

代码示例来源:origin: stackoverflow.com

AlertDialog dlg = eula.show();
WindowManager.LayoutParams lp = dlg.getWindow().getAttributes();
lp.dimAmount = 0.0F;
dlg.getWindow().setAttributes(lp);
dlg.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

代码示例来源:origin: stackoverflow.com

AlertDialog d = builder.create();
d.getWindow().setSoftInputMode(
  WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
d.show();

代码示例来源:origin: stackoverflow.com

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();

代码示例来源:origin: stackoverflow.com

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();
  }
}

代码示例来源:origin: guoxiaoxing/phoenix

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);
    }
  }
}

代码示例来源:origin: stackoverflow.com

alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

代码示例来源:origin: Neamar/KISS

dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

代码示例来源:origin: Neamar/KISS

dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

相关文章