當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。