當前位置: 首頁>>代碼示例>>Java>>正文


Java DialogFragment類代碼示例

本文整理匯總了Java中android.support.v4.app.DialogFragment的典型用法代碼示例。如果您正苦於以下問題:Java DialogFragment類的具體用法?Java DialogFragment怎麽用?Java DialogFragment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DialogFragment類屬於android.support.v4.app包,在下文中一共展示了DialogFragment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCallback

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
public void testCallback() throws Throwable {
  final WritableMap options = new WritableNativeMap();
  options.putDouble("date", getDateInMillis(2020, 5, 6));

  final DialogFragment datePickerFragment = showDialog(options);

  runTestOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          ((DatePickerDialog) datePickerFragment.getDialog())
              .getButton(DialogInterface.BUTTON_POSITIVE).performClick();
        }
      });

  getInstrumentation().waitForIdleSync();
  waitForBridgeAndUIIdle();

  assertEquals(0, mRecordingModule.getErrors());
  assertEquals(1, mRecordingModule.getDates().size());
  assertEquals(2020, (int) mRecordingModule.getDates().get(0)[0]);
  assertEquals(5, (int) mRecordingModule.getDates().get(0)[1]);
  assertEquals(6, (int) mRecordingModule.getDates().get(0)[2]);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:25,代碼來源:DatePickerDialogTestCase.java

示例2: testDismissCallback

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
public void testDismissCallback() throws Throwable {
  final DialogFragment fragment = showDialog(null);

  assertEquals(0, mRecordingModule.getDismissed());

  runTestOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          fragment.getDialog().dismiss();
        }
      });

  getInstrumentation().waitForIdleSync();
  waitForBridgeAndUIIdle();

  assertEquals(0, mRecordingModule.getErrors());
  assertEquals(0, mRecordingModule.getTimes().size());
  assertEquals(1, mRecordingModule.getDismissed());
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:21,代碼來源:TimePickerDialogTestCase.java

示例3: onEventMainThread

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
public void onEventMainThread(ThrowableFailureEvent event) {
    if (!isInExecutionScope(executionScope, event)) {
        return;
    }
    checkLogException(event);
    // Execute pending commits before finding to avoid multiple error fragments being shown
    FragmentManager fm = getFragmentManager();
    fm.executePendingTransactions();

    DialogFragment existingFragment = (DialogFragment) fm.findFragmentByTag(TAG_ERROR_DIALOG);
    if (existingFragment != null) {
        // Just show the latest error
        existingFragment.dismiss();
    }

    DialogFragment errorFragment = (DialogFragment) factory
            .prepareErrorFragment(event, finishAfterDialog, argumentsForErrorDialog);
    if (errorFragment != null) {
        errorFragment.show(fm, TAG_ERROR_DIALOG);
    }
}
 
開發者ID:weileng11,項目名稱:KUtils-master,代碼行數:22,代碼來源:ErrorDialogManager.java

示例4: onBackPressed

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
/**
 * 監聽返回鍵
 */
private void onBackPressed() {
    //設置窗口以對話框樣式顯示
    setStyle(DialogFragment.STYLE_NO_TITLE, R.style.Dialog);
    //設置對話框背景色,否則有虛框
    getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    getDialog().setCancelable(isCancelable);
    getDialog().setCanceledOnTouchOutside(isCancelableTouchOutSide);

    getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
                if (isBack) {
                    onCancel();
                }
                return !isBack;
            }

            return false;
        }
    });
}
 
開發者ID:GitPhoenix,項目名稱:VanGogh,代碼行數:26,代碼來源:BaseDialogFragment.java

示例5: onCreate

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_guide);
    ArrayList<Integer> layouts = new ArrayList<>();

    List<Integer> list = Arrays.asList(R.layout.view_guide_one,
            R.layout.view_guide_two,
            R.layout.view_guide_three,
            R.layout.view_guide_four);
    layouts.addAll(list);


    DialogFragment guideFg = GuideFragment.newInstance(0.85f, 0.7f, layouts);
    FragmentManager fm = getSupportFragmentManager();
    guideFg.show(fm, "guide fg");
}
 
開發者ID:leobert-lan,項目名稱:UiLib,代碼行數:18,代碼來源:GuideActivity.java

示例6: newInstance

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
/**
 * Factory method for creating the DialogFragment with a listener.
 * @param item        QuadrantItem being manipulated
 * @param listener    Listener for passing back the information to update item in QuadrantItem
 * @return            New EditItemDialogFragment instance
 */
public static DialogFragment newInstance(QuadrantItem item, ModifyItemListener listener,
                                         String title) {

  // Initialize new EditItemDialogFragment fragment
  DialogFragment dialog = new EditItemDialogFragment();

  // Pass itemUid to onCreateDialog
  Bundle args = new Bundle();
  args.putParcelable("quadrantItem", item);
  dialog.setArguments(args);

  // Set the listener
  ((EditItemDialogFragment) dialog).setListener(listener);
  ((ModifyItemDialogFragment) dialog).setTitle(title);

  // Return the dialog
  return dialog;
}
 
開發者ID:Austin-Ray,項目名稱:Hexis,代碼行數:25,代碼來源:EditItemDialogFragment.java

示例7: createView

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
@Override
protected View createView(ViewGroup parent) {
    View root = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.dialog_option, parent, false);

    TextView title = (TextView) root.findViewById(R.id.preference_dialog_title);
    TextView detail = (TextView) root.findViewById(R.id.preference_dialog_description);
    mDetailTextView = new WeakReference<>(detail);

    title.setText(getTitle());
    detail.setText(getSelection().getName());

    root.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogFragment fragment = ListDialogFragment.create(getValues(), getSelection());
            fragment.setTargetFragment(getFragment(), getOptionId());
            fragment.show(getFragment().getFragmentManager(), DIALOG_TAG);
        }
    });

    return root;
}
 
開發者ID:marverenic,項目名稱:Options,代碼行數:24,代碼來源:DialogListOption.java

示例8: testPresetDate

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
public void testPresetDate() {
  final WritableMap options = new WritableNativeMap();
  options.putDouble("date", getDateInMillis(2020, 5, 6));

  final DialogFragment datePickerFragment = showDialog(options);
  final DatePicker datePicker =
      ((DatePickerDialog) datePickerFragment.getDialog()).getDatePicker();

  assertEquals(2020, datePicker.getYear());
  assertEquals(5, datePicker.getMonth());
  assertEquals(6, datePicker.getDayOfMonth());
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:13,代碼來源:DatePickerDialogTestCase.java

示例9: onNoteEditPositiveClock

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
@Override
public void onNoteEditPositiveClock(String str, DialogFragment dialog) {
    ContentValues values = new ContentValues();
    values.put(ActivityDiaryContract.Diary.NOTE, str);

    mQHandler.startUpdate(0,
            null,
            mCurrentDiaryUri,
            values,
            null, null);
    mNoteTextView.setText(str);
    ActivityHelper.helper.setCurrentNote(str);
}
 
開發者ID:ramack,項目名稱:ActivityDiary,代碼行數:14,代碼來源:MainActivity.java

示例10: dismissDialog

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
protected boolean dismissDialog() {
    boolean isVisible = false;
    Fragment prev = getSupportFragmentManager().findFragmentByTag(LoadingDialog.DIALOG_TAG);
    if (prev != null) {
        DialogFragment df = (DialogFragment) prev;
        df.dismiss();
        isVisible = true;
    }
    return isVisible;
}
 
開發者ID:CactusSoft,項目名稱:zabbkit-android,代碼行數:11,代碼來源:LoadingDialogActivity.java

示例11: onCreateDialogFragment

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
@NonNull
@Override
protected DialogFragment onCreateDialogFragment(String key) {
    final HttpUriPreferenceDialogFragment fragment = new HttpUriPreferenceDialogFragment();
    final Bundle b  = new Bundle(1);
    b.putString(PreferenceDialogFragment.ARG_KEY, key);
    b.putString(HttpUriPreferenceDialogFragment.ARG_KEY_USERNAME, keyUsername);
    b.putString(HttpUriPreferenceDialogFragment.ARG_KEY_PASSWORD, keyPassword);
    fragment.setArguments(b);
    return fragment;
}
 
開發者ID:RikkaApps,項目名稱:FCM-for-Mojo,代碼行數:12,代碼來源:HttpUriPreference.java

示例12: onCreateHomeScreenShortcutCreate

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
@Override
public void onCreateHomeScreenShortcutCreate(DialogFragment dialog) {

    Intent bookmarkShortcut = new Intent();
    bookmarkShortcut.setAction(Intent.ACTION_VIEW);
    bookmarkShortcut.setData(Uri.parse(UrlCleaner));
    Intent shortcutMaker = new Intent();
    shortcutMaker.putExtra("duplicate", false);
    shortcutMaker.putExtra("android.intent.extra.shortcut.INTENT", bookmarkShortcut);
    shortcutMaker.putExtra("android.intent.extra.shortcut.ICON", favoriteIcon);
    shortcutMaker.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    sendBroadcast(shortcutMaker);
}
 
開發者ID:sfilmak,項目名稱:MakiLite,代碼行數:14,代碼來源:MainActivity.java

示例13: showDialog

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
public void showDialog(ArrayList<Boolean> state) {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment prev = getFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    //String inputText = inputTextField.getText().toString();

    DialogFragment newFragment = MyDialogFragment.newInstance(state, list);
    newFragment.show(ft, "dialog");

}
 
開發者ID:icaynia,項目名稱:pracler,代碼行數:15,代碼來源:MyMusicListFragment.java

示例14: showDialog

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
private void showDialog(final DialogFragment dialog, final String nameOfFragment) {
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    final Fragment prev = getSupportFragmentManager().findFragmentByTag(nameOfFragment);
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);
    dialog.show(ft, nameOfFragment);
}
 
開發者ID:videgro,項目名稱:Ships,代碼行數:10,代碼來源:OpenDeviceActivity.java

示例15: showFileDialog

import android.support.v4.app.DialogFragment; //導入依賴的package包/類
private static void showFileDialog(FragmentActivity activity, FileDialog dialog) {
    Bundle args = new Bundle();
    args.putString(FileDialog.EXTENSION, REPOSITORY_EXTENSION);
    dialog.setArguments(args);
    dialog.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.AppTheme);
    dialog.show(activity.getSupportFragmentManager(), OpenFileDialog.class.getName());
}
 
開發者ID:djuelg,項目名稱:Neuronizer,代碼行數:8,代碼來源:FileDialogs.java


注:本文中的android.support.v4.app.DialogFragment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。