当前位置: 首页>>代码示例>>Java>>正文


Java Dialog.setOnShowListener方法代码示例

本文整理汇总了Java中android.app.Dialog.setOnShowListener方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.setOnShowListener方法的具体用法?Java Dialog.setOnShowListener怎么用?Java Dialog.setOnShowListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Dialog的用法示例。


在下文中一共展示了Dialog.setOnShowListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateDialog

import android.app.Dialog; //导入方法依赖的package包/类
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(dialogInterface -> {
        if (ViewHelper.isTablet(getActivity())) {
            if (dialog.getWindow() != null) {
                dialog.getWindow().setLayout(
                        ViewGroup.LayoutParams.WRAP_CONTENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
            }
        }
        onDialogIsShowing();
    });
    dialog.setOnKeyListener((dialog1, keyCode, event) -> {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            isAlreadyHidden = true;
            onDismissedByScrolling();
        }
        return false;
    });
    return dialog;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:22,代码来源:BaseBottomSheetDialog.java

示例2: getDialog

import android.app.Dialog; //导入方法依赖的package包/类
@NonNull
private Dialog getDialog() {
  final Dialog dialog = new AlertDialog.Builder(FeedActivity.this)
      .setTitle("Create a new Feed Entry")
      .setView(dialogFeedEntryBinding.getRoot())
      .setPositiveButton("Submit", null)
      .setNegativeButton("Cancel", (dialogInterface, i) -> dialogInterface.dismiss())
      .create();
  dialog.setOnShowListener(dialogInterface -> {
    Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
    button.setOnClickListener(view1 -> {
      // TODO Do something
      //to trigger auto error enable
      //get the binding
      inputFeedEntry = dialogFeedEntryBinding.getFeedEntry();
      Boolean[] validations = new Boolean[]{
          dialogFeedEntryBinding.imageUrlValidation.isErrorEnabled(),
          dialogFeedEntryBinding.titleValidation.isErrorEnabled(),
          dialogFeedEntryBinding.subTitleValidation.isErrorEnabled()
      };
      boolean isValid = true;
      //check the validation
      for (Boolean validation : validations) {
        if (validation) {
          isValid = false;
        }
      }
      //insert the record
      if (isValid) {
        Single.create(subscriber -> viewModel.insert(inputFeedEntry))
            .subscribeOn(Schedulers.newThread())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe();
        dialogInterface.dismiss();
      }
    });
  });
  return dialog;
}
 
开发者ID:charlesng,项目名称:SampleAppArch,代码行数:40,代码来源:FeedActivity.java

示例3: onCreateDialog

import android.app.Dialog; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.getWindow().setLayout(
                    parentWidth - Utils.dpToPx(0, getContext()), // Set margins here!
                    ViewGroup.LayoutParams.MATCH_PARENT);
        }
    });
    return dialog;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:16,代码来源:ShareChooserDialog.java

示例4: setPositiveButtonListener

import android.app.Dialog; //导入方法依赖的package包/类
/**
 * Set the listener of the positive button.
 * @param dialog  Dialog to set the listener of
 * @return        Dialog with listener added.
 */
protected Dialog setPositiveButtonListener(Dialog dialog) {
  dialog.setOnShowListener(dialog1 -> {
    Button button = ((AlertDialog) dialog1).getButton(AlertDialog.BUTTON_POSITIVE);
    button.setOnClickListener(this);
  });

  return dialog;
}
 
开发者ID:Austin-Ray,项目名称:Hexis,代码行数:14,代码来源:ModifyItemDialogFragment.java

示例5: onCreateDialog

import android.app.Dialog; //导入方法依赖的package包/类
@NonNull
@Override public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    if (!PrefGetter.isAppAnimationDisabled() && !(this instanceof ProgressDialogFragment)) {
        dialog.setOnShowListener(dialogInterface -> AnimHelper.revealDialog(dialog,
                getResources().getInteger(android.R.integer.config_longAnimTime)));
    }
    return dialog;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:10,代码来源:BaseDialogFragment.java

示例6: onCreateDialog

import android.app.Dialog; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = new AlertDialog.Builder(getActivity())
            .setTitle(R.string.mp_play_list_dialog_add_to)
            .setView(R.layout.dialog_add_to_play_list)
            .setNegativeButton(R.string.mp_cancel, null)
            .create();
    dialog.setOnShowListener(this);
    return dialog;
}
 
开发者ID:xxczaki,项目名称:music-player,代码行数:12,代码来源:AddToPlayListDialogFragment.java

示例7: onCreateDialog

import android.app.Dialog; //导入方法依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // 使用不带theme的构造器,获得的dialog边框距离屏幕仍有几毫米的缝隙。
    Dialog dialog = new Dialog(getActivity(), R.style.Theme_Light_NoTitle_Dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // must be called before set content
    dialog.setContentView(R.layout.edit_menu_bar);
    dialog.setCanceledOnTouchOutside(true);

    // 设置宽度为屏宽、靠近屏幕底部。
    Window window = dialog.getWindow();
    WindowManager.LayoutParams wlp = window.getAttributes();
    wlp.gravity = Gravity.BOTTOM;
    wlp.width = WindowManager.LayoutParams.MATCH_PARENT;
    window.setAttributes(wlp);
    window.setWindowAnimations(R.style.Animation_Bottom);

    //init other widget and set listener
    saveButton =  dialog.findViewById(R.id.save);
    editEvent = dialog.findViewById(R.id.edit_event);

    saveButton.setOnClickListener(this);

    //获得传入的适配器和当前事件类别
    Bundle bundle = getArguments();
    adapter = (EventsAdapter) bundle.getSerializable("adapter");
    category = bundle.getInt("category");

    // 当点击软件盘确定按钮时, 保存文本
    editEvent.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if(!editEvent.getText().toString().isEmpty()) {
                saveButton.performClick();
            }
            else{
                return true;
            }
            return false;
        }
    });

    // 设置editText获取焦点并自动弹出键盘
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            if(editEvent!=null){
                //设置可获得焦点
                editEvent.setFocusable(true);
                editEvent.setFocusableInTouchMode(true);
                //请求获得焦点
                editEvent.requestFocus();
                //调用系统输入法
                InputMethodManager inputManager = (InputMethodManager) editEvent.getContext().
                        getSystemService(Context.INPUT_METHOD_SERVICE);
                inputManager.showSoftInput(editEvent, InputMethodManager.SHOW_IMPLICIT);
            }

        }
    });
    return dialog;
}
 
开发者ID:wendyltan,项目名称:EasyTodo,代码行数:62,代码来源:EditMenuFragment.java


注:本文中的android.app.Dialog.setOnShowListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。