android.app.Dialog.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(193)

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

Dialog.<init>介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

public Dialog getErrorDialog(int errorCode, Activity activity, int requestCode,
  OnCancelListener cancelListener) {
 if (errorCode == ConnectionResult.SUCCESS) {
  return null;
 }
 return new Dialog(RuntimeEnvironment.application);
}

代码示例来源:origin: robolectric/robolectric

@Override
 protected Dialog onCreateDialog(int id) {
  return new Dialog(this);
 }
}

代码示例来源:origin: robolectric/robolectric

@Override
 protected Dialog onCreateDialog(int id) {
  onCreateDialogWasCalled = true;
  return new Dialog(this);
 }
}

代码示例来源:origin: lipangit/JiaoZiVideoPlayer

public Dialog createDialogWithView(View localView) {
  Dialog dialog = new Dialog(getContext(), R.style.jz_style_dialog_progress);
  dialog.setContentView(localView);
  Window window = dialog.getWindow();
  window.addFlags(Window.FEATURE_ACTION_BAR);
  window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
  window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
  window.setLayout(-2, -2);
  WindowManager.LayoutParams localLayoutParams = window.getAttributes();
  localLayoutParams.gravity = Gravity.CENTER;
  window.setAttributes(localLayoutParams);
  return dialog;
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

public static Dialog showDialogForLoading(Activity context) {
  View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null);
  TextView loadingText = (TextView)view.findViewById(R.id.id_tv_loading_dialog_text);
  loadingText.setText("加载中...");
  mLoadingDialog = new Dialog(context, R.style.CustomProgressDialog);
  mLoadingDialog.setCancelable(true);
  mLoadingDialog.setCanceledOnTouchOutside(false);
  mLoadingDialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
  mLoadingDialog.show();
  return  mLoadingDialog;
}

代码示例来源:origin: libgdx/libgdx

Dialog createDialog () {
  textView = createView(context);
  textView.setOnKeyListener(this);
  FrameLayout.LayoutParams textBoxLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
    FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
  textView.setLayoutParams(textBoxLayoutParams);
  textView.setFocusable(true);
  textView.setFocusableInTouchMode(true);
  textView.setImeOptions(textView.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
  final FrameLayout layout = new FrameLayout(context);
  ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
  layout.setLayoutParams(layoutParams);
  layout.addView(textView);
  layout.setOnTouchListener(this);
  dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
  dialog.setContentView(layout);
  return dialog;
}

代码示例来源:origin: libgdx/libgdx

Dialog createDialog () {
  textView = createView(context);
  textView.setOnKeyListener(this);
  FrameLayout.LayoutParams textBoxLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
    FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
  textView.setLayoutParams(textBoxLayoutParams);
  textView.setFocusable(true);
  textView.setFocusableInTouchMode(true);
  textView.setImeOptions(textView.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
  final FrameLayout layout = new FrameLayout(context);
  ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
  layout.setLayoutParams(layoutParams);
  layout.addView(textView);
  layout.setOnTouchListener(this);
  dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
  dialog.setContentView(layout);
  return dialog;
}

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

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  dialog = new Dialog(getActivity(), R.style.com_facebook_auth_dialog);
  View view = initializeContentView(DeviceRequestsHelper.isAvailable() && !this.isRetry);
  dialog.setContentView(view);
  return dialog;
}

代码示例来源:origin: facebook/stetho

@Override
 public void onClick(View v) {
  int id = v.getId();
  if (id == R.id.settings_btn) {
   SettingsActivity.show(MainActivity.this);
  } else if (id == R.id.apod_btn) {
   APODActivity.show(MainActivity.this);
  } else if (id == R.id.irc_btn) {
   IRCConnectActivity.show(MainActivity.this);
  } else if (id == R.id.about) {
   View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.dialog_layout, null);
   Dialog dialog = new Dialog(MainActivity.this);
   dialog.setContentView(view);
   dialog.setTitle(getString(R.string.app_name));
   dialog.show();
  }
 }
};

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = KITKAT)
public void show_shouldWorkWithAPI19() {
 Dialog dialog = new Dialog(context);
 dialog.show();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldCallOnDismissListener() throws Exception {
 final List<String> transcript = new ArrayList<>();
 final Dialog dialog = new Dialog(context);
 dialog.show();
 dialog.setOnDismissListener(
   dialogInListener -> {
    assertThat(dialogInListener).isSameAs(dialog);
    transcript.add("onDismiss called!");
   });
 dialog.dismiss();
 assertThat(transcript).containsExactly("onDismiss called!");
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldFindViewsWithinAContentViewThatWasPreviouslySet() throws Exception {
 Dialog dialog = new Dialog(context);
 dialog.setContentView(dialog.getLayoutInflater().inflate(R.layout.main, null));
 assertThat(dialog.<TextView>findViewById(R.id.title)).isInstanceOf((Class<? extends TextView>) TextView.class);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void setContentViewWithViewAllowsFindById() throws Exception {
 final int viewId = 1234;
 final Dialog dialog = new Dialog(context);
 final View view = new View(context);
 view.setId(viewId);
 dialog.setContentView(view);
 assertSame(view, dialog.findViewById(viewId));
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getLatestDialog_shouldReturnARealDialog() throws Exception {
 assertThat(ShadowDialog.getLatestDialog()).isNull();
 Dialog dialog = new Dialog(context);
 dialog.show();
 assertThat(ShadowDialog.getLatestDialog()).isSameAs(dialog);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldGetLayoutInflater() {
 Dialog dialog = new Dialog(context);
 assertNotNull(dialog.getLayoutInflater());
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldDefaultCancelableToTrueAsTheSDKDoes() throws Exception {
 Dialog dialog = new Dialog(context);
 ShadowDialog shadow = shadowOf(dialog);
 assertThat(shadow.isCancelable()).isTrue();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void canSetAndGetOnCancelListener() {
 Dialog dialog = new Dialog(context);
 DialogInterface.OnCancelListener onCancelListener = dialog1 -> {};
 dialog.setOnCancelListener(onCancelListener);
 assertThat(onCancelListener).isSameAs(shadowOf(dialog).getOnCancelListener());
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldSetCancelable() {
 Dialog dialog = new Dialog(context);
 ShadowDialog shadow = shadowOf(dialog);
 dialog.setCancelable(false);
 assertThat(shadow.isCancelable()).isFalse();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void show_setsLatestDialog() {
 Dialog dialog = new Dialog(context);
 assertNull(ShadowDialog.getLatestDialog());
 dialog.show();
 assertSame(dialog, ShadowDialog.getLatestDialog());
 assertNull(ShadowAlertDialog.getLatestAlertDialog());
}

代码示例来源:origin: robolectric/robolectric

@Test
public void show_shouldShowDialogThatWasReturnedFromOnCreateDialog_whenOnCreateDialogReturnsADialog() throws Exception {
 Dialog dialogFromOnCreateDialog = new Dialog(activity);
 dialogFragment.returnThisDialogFromOnCreateDialog(dialogFromOnCreateDialog);
 dialogFragment.show(fragmentManager, "this is a tag");
 Dialog dialog = ShadowDialog.getLatestDialog();
 assertSame(dialogFromOnCreateDialog, dialog);
 assertSame(dialogFromOnCreateDialog, dialogFragment.getDialog());
 assertSame(dialogFragment, fragmentManager.findFragmentByTag("this is a tag"));
}

相关文章