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