本文整理汇总了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]);
}
示例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());
}
示例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);
}
}
示例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;
}
});
}
示例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");
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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");
}
示例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);
}
示例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());
}