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


Java Preference.getContext方法代碼示例

本文整理匯總了Java中android.preference.Preference.getContext方法的典型用法代碼示例。如果您正苦於以下問題:Java Preference.getContext方法的具體用法?Java Preference.getContext怎麽用?Java Preference.getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.preference.Preference的用法示例。


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

示例1: updateKeyboardThemeSummary

import android.preference.Preference; //導入方法依賴的package包/類
static void updateKeyboardThemeSummary(final Preference pref) {
    final Context context = pref.getContext();
    final Resources res = context.getResources();
    final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(context);
    final String[] keyboardThemeNames = res.getStringArray(R.array.keyboard_theme_names);
    final int[] keyboardThemeIds = res.getIntArray(R.array.keyboard_theme_ids);
    for (int index = 0; index < keyboardThemeNames.length; index++) {
        if (keyboardTheme.mThemeId == keyboardThemeIds[index]) {
            pref.setSummary(keyboardThemeNames[index]);
            return;
        }
    }
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:14,代碼來源:ThemeSettingsFragment.java

示例2: onPreferenceChange

import android.preference.Preference; //導入方法依賴的package包/類
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    final Context context = preference.getContext();
    if (Boolean.parseBoolean(newValue.toString())) {
        if (!isValidServerSetup(context)) {
            Toast.makeText(context, R.string.provide_user_pass_url, Toast.LENGTH_LONG).show();
            return false;
        }
    }
    return true;
}
 
開發者ID:bfabiszewski,項目名稱:ulogger-android,代碼行數:12,代碼來源:SettingsActivity.java

示例3: onPreferenceClick

import android.preference.Preference; //導入方法依賴的package包/類
@Override
public boolean onPreferenceClick(Preference preference) {
    final Context context = preference.getContext();
    DbAccess db = DbAccess.getInstance();
    db.open(context);
    if (db.getTrackId() > 0) {
        // track saved on server
        Alert.showInfo(context,
                context.getString(R.string.warning),
                context.getString(R.string.track_server_setup_warning)
        );

    }
    return true;
}
 
開發者ID:bfabiszewski,項目名稱:ulogger-android,代碼行數:16,代碼來源:SettingsActivity.java

示例4: updateSubtypeEnabler

import android.preference.Preference; //導入方法依賴的package包/類
public void updateSubtypeEnabler() {
    final Preference pref = mSubtypeEnablerPreference;
    if (pref == null) {
        return;
    }
    final Context context = pref.getContext();
    final CharSequence title;
    if (mSubtypeEnablerTitleRes != 0) {
        title = context.getString(mSubtypeEnablerTitleRes);
    } else {
        title = mSubtypeEnablerTitle;
    }
    pref.setTitle(title);
    final Intent intent = pref.getIntent();
    if (intent != null) {
        intent.putExtra(Intent.EXTRA_TITLE, title);
    }
    final String summary = getEnabledSubtypesLabel(context, mImm, mImi);
    if (!TextUtils.isEmpty(summary)) {
        pref.setSummary(summary);
    }
    if (mSubtypeEnablerIconRes != 0) {
        pref.setIcon(mSubtypeEnablerIconRes);
    } else {
        pref.setIcon(mSubtypeEnablerIcon);
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:28,代碼來源:InputMethodSettingsImpl.java

示例5: onPreferenceChange

import android.preference.Preference; //導入方法依賴的package包/類
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);
        String title = index >= 0 ? String.valueOf(listPreference.getEntries()[index]) : "";
        //Exibir o tempo total de funcionamento do registrador depois do ultimo reset.
        if (OhaEnergyUseSyncHelper.ENERGY_USE_SYNC_OFTEN_LOGGER_RESET.equals(preference.getKey())){
            Context context = preference.getContext();
            long durationLoggerRunning = preference.getSharedPreferences().getLong(OhaEnergyUseSyncHelper.ENERGY_USE_SYNC_DURATION_LOGGER_RUNNING,0);
            preference.setTitle(String.format(context.getString(R.string.pref_title_energy_use_sync_often_logger_reset), title));
            preference.setSummary(String.format(context.getString(R.string.pref_summary_energy_use_sync_often_logger_reset), OhaHelper.convertMillisToHours(durationLoggerRunning)));

        } else {
            // Set the summary to reflect the new value.
            preference.setSummary(title);
        }

    } else if (preference instanceof RingtonePreference) {
        // For ringtone preferences, look up the correct display value
        // using RingtoneManager.
        if (!TextUtils.isEmpty(stringValue)) {
            Ringtone ringtone = RingtoneManager.getRingtone(
                    preference.getContext(), Uri.parse(stringValue));

            if (ringtone == null) {
                // Clear the summary if there was a lookup error.
                preference.setSummary(null);
            } else {
                // Set the summary to reflect the new ringtone display
                // name.
                String name = ringtone.getTitle(preference.getContext());
                preference.setSummary(name);
            }
        }

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
開發者ID:brolam,項目名稱:OpenHomeAnalysis,代碼行數:48,代碼來源:AppCompatPreferenceHelper.java


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