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


Java DialogPreference类代码示例

本文整理汇总了Java中android.preference.DialogPreference的典型用法代码示例。如果您正苦于以下问题:Java DialogPreference类的具体用法?Java DialogPreference怎么用?Java DialogPreference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onPreferenceClick

import android.preference.DialogPreference; //导入依赖的package包/类
@Override
public boolean onPreferenceClick(final Preference preference) {
    new AlertDialog.Builder(settingsActivity)
            .setTitle(settingsActivity.getString(R.string.app_logout))
            .setMessage(settingsActivity.getString(R.string.settings_menu_logout_message))
            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface arg0, int arg1) {
                    logout();
                }
            })
            .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    ((DialogPreference) preference).getDialog().dismiss();
                    dialog.cancel();
                }
            }).create().show();
    return true;
}
 
开发者ID:EyeSeeTea,项目名称:pictureapp,代码行数:19,代码来源:LogoutAndLoginRequiredOnPreferenceClickListener.java

示例2: expandDialog

import android.preference.DialogPreference; //导入依赖的package包/类
protected void expandDialog(Preference preference) {
	if (preference instanceof DialogPreference) {
		try {
			if (preference.getPreferenceManager() == null) {
				Method onAttachedToHierarchy = Preference.class.getDeclaredMethod("onAttachedToHierarchy",
						PreferenceManager.class);
				onAttachedToHierarchy.setAccessible(true);
				onAttachedToHierarchy.invoke(preference, getPreferenceManager());
			}
			Method onClickMethod = Preference.class.getDeclaredMethod("onClick");
			onClickMethod.setAccessible(true);
			onClickMethod.invoke(preference);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
 
开发者ID:Mishiranu,项目名称:Dashchan,代码行数:18,代码来源:BasePreferenceFragment.java

示例3: addExportMorguePreference

import android.preference.DialogPreference; //导入依赖的package包/类
private void addExportMorguePreference() {
    DialogPreference backupDialogPreference = new DialogPreference(this,
            null) {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    // Get stuff in edittext, back it up to that directory
                    EditText directoryBox = (EditText) getDialog()
                            .findViewById(R.id.directoryBox);
                    String destination = directoryBox.getText().toString();
                    backupDirectory(destination, "/morgue");
                    break;
            }
        }
    };
    backupDialogPreference.setDialogLayoutResource(R.layout.backup_morgue_dialog);
    backupDialogPreference.setDialogTitle(R.string.backup_morgue_directory);
    backupDialogPreference.setTitle(R.string.backup_morgue_directory);
    backupDialogPreference.setPositiveButtonText(R.string.backup);
    backupDialogPreference.setNegativeButtonText(android.R.string.cancel);

    PreferenceCategory saveFilesCategory = (PreferenceCategory) findPreference("morgue");
    saveFilesCategory.addPreference(backupDialogPreference);
}
 
开发者ID:michaelbarlow7,项目名称:dungeon-crawl-android,代码行数:26,代码来源:PreferencesActivity.java

示例4: addExportSavePreference

import android.preference.DialogPreference; //导入依赖的package包/类
private void addExportSavePreference() {
    DialogPreference backupDialogPreference = new DialogPreference(this,
            null) {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    // Get stuff in edittext, back it up to that directory
                    EditText directoryBox = (EditText) getDialog()
                            .findViewById(R.id.directoryBox);
                    String destination = directoryBox.getText().toString();
                    backupDirectory(destination, "/saves");
                    break;
            }
        }
    };
    backupDialogPreference.setDialogLayoutResource(R.layout.backup_saves_dialog);
    backupDialogPreference.setDialogTitle(R.string.backup_save_directory);
    backupDialogPreference.setTitle(R.string.backup_save_directory);
    backupDialogPreference.setPositiveButtonText(R.string.backup);
    backupDialogPreference.setNegativeButtonText(android.R.string.cancel);

    PreferenceCategory saveFilesCategory = (PreferenceCategory) findPreference("saveFiles");
    saveFilesCategory.addPreference(backupDialogPreference);

}
 
开发者ID:michaelbarlow7,项目名称:dungeon-crawl-android,代码行数:27,代码来源:PreferencesActivity.java

示例5: addRestoreSavePreference

import android.preference.DialogPreference; //导入依赖的package包/类
private void addRestoreSavePreference() {
    DialogPreference backupDialogPreference = new DialogPreference(this,
            null) {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    // Get stuff in edittext, restore it from that directory
                    EditText directoryBox = (EditText) getDialog()
                            .findViewById(R.id.directoryBox);
                    String source = directoryBox.getText().toString();
                    restoreDirectory(source, "/saves");
                    break;
            }
        }
    };
    backupDialogPreference.setDialogLayoutResource(R.layout.restore_saves_dialog);
    backupDialogPreference.setDialogTitle(R.string.restore_save_directory);
    backupDialogPreference.setTitle(R.string.restore_save_directory);
    backupDialogPreference.setPositiveButtonText(R.string.restore);
    backupDialogPreference.setNegativeButtonText(android.R.string.cancel);

    PreferenceCategory saveFilesCategory = (PreferenceCategory) findPreference("saveFiles");
    saveFilesCategory.addPreference(backupDialogPreference);

}
 
开发者ID:michaelbarlow7,项目名称:dungeon-crawl-android,代码行数:27,代码来源:PreferencesActivity.java

示例6: addRestoreMorguePreference

import android.preference.DialogPreference; //导入依赖的package包/类
private void addRestoreMorguePreference() {
    DialogPreference backupDialogPreference = new DialogPreference(this,
            null) {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    // Get stuff in edittext, restore it from that directory
                    EditText directoryBox = (EditText) getDialog()
                            .findViewById(R.id.directoryBox);
                    String source = directoryBox.getText().toString();
                    restoreDirectory(source, "/morgue");
                    break;
            }
        }
    };
    backupDialogPreference.setDialogLayoutResource(R.layout.restore_morgue_dialog);
    backupDialogPreference.setDialogTitle(R.string.restore_morgue_directory);
    backupDialogPreference.setTitle(R.string.restore_morgue_directory);
    backupDialogPreference.setPositiveButtonText(R.string.restore);
    backupDialogPreference.setNegativeButtonText(android.R.string.cancel);

    PreferenceCategory saveFilesCategory = (PreferenceCategory) findPreference("morgue");
    saveFilesCategory.addPreference(backupDialogPreference);

}
 
开发者ID:michaelbarlow7,项目名称:dungeon-crawl-android,代码行数:27,代码来源:PreferencesActivity.java

示例7: DoubleNumberPickerPreference

import android.preference.DialogPreference; //导入依赖的package包/类
public DoubleNumberPickerPreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray dialogType = context.obtainStyledAttributes(attrs,
            R.styleable.DialogPreference, 0, 0);
    TypedArray doubleNumberPickerType = context.obtainStyledAttributes(attrs,
            R.styleable.DoubleNumberPickerPreference, 0, 0);

    mMaxExternalKey1 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_maxExternal1);
    mMinExternalKey1 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_minExternal1);
    mMaxExternalKey2 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_maxExternal2);
    mMinExternalKey2 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_minExternal2);

    mPickerTitle1 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_pickerTitle1);
    mPickerTitle2 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_pickerTitle2);

    mMax1 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_max1, 5);
    mMin1 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_min1, 0);
    mMax2 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_max2, 5);
    mMin2 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_min2, 0);

    mDefault1 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_defaultValue1, mMin1);
    mDefault2 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_defaultValue2, mMin2);

    dialogType.recycle();
    doubleNumberPickerType.recycle();
}
 
开发者ID:Lesik,项目名称:open-gel-plus,代码行数:27,代码来源:DoubleNumberPickerPreference.java

示例8: type

import android.preference.DialogPreference; //导入依赖的package包/类
public static SubjectFactory<DialogPreferenceSubject, DialogPreference> type() {
  return new SubjectFactory<DialogPreferenceSubject, DialogPreference>() {
    @Override
    public DialogPreferenceSubject getSubject(FailureStrategy fs, DialogPreference that) {
      return new DialogPreferenceSubject(fs, that);
    }
  };
}
 
开发者ID:pkware,项目名称:truth-android,代码行数:9,代码来源:DialogPreferenceSubject.java

示例9: addCustomPreferecences

import android.preference.DialogPreference; //导入依赖的package包/类
private void addCustomPreferecences() {
    //noinspection deprecation
    final DialogPreference prefSyncTime = (DialogPreference)findPreference(getString(string.pref_synctime_key));
    final Context context = this;

    prefSyncTime.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            TimePicker timePicker = (TimePicker) prefSyncTime.getDialog().findViewById(R.id.timePicker);
            final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
            String[] syncTime = preferences.getString(getString(R.string.pref_synctime_key),
                    getString(string.pref_synctime_default)).split(":");
            int syncHour = Integer.parseInt(syncTime[0]);
            int syncMinute = Integer.parseInt(syncTime[1]);
            timePicker.setCurrentHour(syncHour);
            timePicker.setCurrentMinute(syncMinute);
            timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
                @Override
                public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
                    Preference.OnPreferenceChangeListener listener = prefSyncTime.getOnPreferenceChangeListener();
                    String value = String.format("%d:%d", hourOfDay, minute);
                    preferences.edit().putString(context.getString(R.string.pref_synctime_key), value).apply();
                    if (listener != null) {
                        listener.onPreferenceChange(prefSyncTime, value);
                    }
                }
            });
            return true;
        }
    });
}
 
开发者ID:hmrs-cr,项目名称:android-nmea-logger,代码行数:32,代码来源:SettingsActivity.java

示例10: run

import android.preference.DialogPreference; //导入依赖的package包/类
@Override
public void run() {
    PreferenceFragment preferenceFragment = (PreferenceFragment) mPreferencesActivity
            .getFragmentManager().findFragmentById(android.R.id.content);
    DialogPreference dialogPreference = (DialogPreference) preferenceFragment
            .findPreference(mKey);
    mSummary = dialogPreference.getSummary().toString();
}
 
开发者ID:google,项目名称:talkback,代码行数:9,代码来源:TalkBackKeyboardShortcutPreferencesActivityTest.java

示例11: run

import android.preference.DialogPreference; //导入依赖的package包/类
@Override
public void run() {
    PreferenceFragment preferenceFragment =
            (PreferenceFragment) mActivity.getFragmentManager().findFragmentById(
                    android.R.id.content);
    DialogPreference dialogPreference =
            (DialogPreference) preferenceFragment.findPreference(
                    mActivity.getString(R.string.keycombo_shortcut_navigate_next));
    mEnabled = dialogPreference.isEnabled();
}
 
开发者ID:google,项目名称:talkback,代码行数:11,代码来源:KeyboardShortcutDialogPreferenceTest.java

示例12: DialogPreferenceSubject

import android.preference.DialogPreference; //导入依赖的package包/类
protected DialogPreferenceSubject(FailureStrategy failureStrategy, DialogPreference subject) {
  super(failureStrategy, subject);
}
 
开发者ID:pkware,项目名称:truth-android,代码行数:4,代码来源:DialogPreferenceSubject.java

示例13: shadowOf

import android.preference.DialogPreference; //导入依赖的package包/类
public static ShadowDialogPreference shadowOf(DialogPreference instance) {
  return (ShadowDialogPreference) shadowOf_(instance);
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:4,代码来源:Robolectric.java

示例14: DialogPreferenceAssert

import android.preference.DialogPreference; //导入依赖的package包/类
public DialogPreferenceAssert(DialogPreference actual) {
  super(actual, DialogPreferenceAssert.class);
}
 
开发者ID:square,项目名称:assertj-android,代码行数:4,代码来源:DialogPreferenceAssert.java


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