本文整理汇总了Java中android.preference.ListPreference.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java ListPreference.setTitle方法的具体用法?Java ListPreference.setTitle怎么用?Java ListPreference.setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.ListPreference
的用法示例。
在下文中一共展示了ListPreference.setTitle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillLayout
import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void fillLayout(final SipProfile account) {
super.fillLayout(account);
CharSequence[] states = new CharSequence[] {"act", "nsw", "nt", "qld", "sa", "tas", "vic", "wa"};
accountState = new ListPreference(parent);
accountState.setEntries(states);
accountState.setEntryValues(states);
accountState.setKey("state");
accountState.setDialogTitle(R.string.w_iinet_state);
accountState.setTitle(R.string.w_iinet_state);
accountState.setSummary(R.string.w_iinet_state_desc);
accountState.setDefaultValue("act");
addPreference(accountState);
String domain = account.reg_uri;
if( domain != null ) {
for(CharSequence state : states) {
String currentComp = "sip:sip."+state+".iinet.net.au";
if( currentComp.equalsIgnoreCase(domain) ) {
accountState.setValue(state.toString());
break;
}
}
}
accountUsername.setTitle(R.string.w_iinet_username);
accountUsername.setDialogTitle(R.string.w_iinet_username);
accountPassword.setTitle(R.string.w_iinet_password);
accountPassword.setDialogTitle(R.string.w_iinet_password);
}
示例2: onViewCreated
import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final PreferenceScreen preferenceScreen = this.getPreferenceScreen();
Thread t = new Thread(new Runnable() {
@Override
public void run() {
ProjectService projectService = new ProjectService();
ArrayList<Project> projects = projectService.getAllProjects();
//Project temp = new Project();
//projects.add(temp.setProjectId(5L).setProjectName("foo").setBuildingName("FFUF"));
PreferenceCategory projectPref = (PreferenceCategory) preferenceScreen.findPreference("pref_key_proj_info");
ListPreference projectIdList = new ListPreference(preferenceScreen.getContext());
projectIdList.setKey("project_id_list");
projectIdList.setTitle("Project");
projectIdList.setSummary("Select the localization project.");
// Get project ids and names from projects list.
String projectNames[] = new String[projects.size()];
String projectIds[] = new String[projects.size()];
Log.i(TAG, "Projects:");
for (int i = 0; i < projects.size(); i++) {
Log.i(TAG, projects.get(i).getProjectId() + " => " + projects.get(i).getProjectName());
projectIds[i] = "" + projects.get(i).getProjectId();
projectNames[i] = projects.get(i).getProjectId() + ": " + projects.get(i).getProjectName() + " (Building: " + projects.get(i).getBuildingName() + ")";
}
// Set drop down entries and initialize preferences.
projectIdList.setEntries(projectNames);
projectIdList.setEntryValues(projectIds);
projectIdList.setOnPreferenceChangeListener(new ProjectPreferenceChangeListener(preferenceScreen));
projectPref.addPreference(projectIdList);
}
});
t.start();
}
示例3: setUpListPreference
import android.preference.ListPreference; //导入方法依赖的package包/类
/**
* Initialize a ListPreference with a certain value.
* @param preference The ListPreference to initialize.
* @param value The value to initialize it to.
*/
private void setUpListPreference(Preference preference, ContentSetting value) {
if (value == null) {
getPreferenceScreen().removePreference(preference);
return;
}
ListPreference listPreference = (ListPreference) preference;
int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey());
CharSequence[] keys = new String[2];
CharSequence[] descriptions = new String[2];
keys[0] = ContentSetting.ALLOW.toString();
keys[1] = ContentSetting.BLOCK.toString();
descriptions[0] = getResources().getString(
ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW));
descriptions[1] = getResources().getString(
ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK));
listPreference.setEntryValues(keys);
listPreference.setEntries(descriptions);
int index = (value == ContentSetting.ALLOW ? 0 : 1);
listPreference.setValueIndex(index);
int explanationResourceId = ContentSettingsResources.getExplanation(contentType);
if (explanationResourceId != 0) {
listPreference.setTitle(explanationResourceId);
}
if (listPreference.isEnabled()) {
SiteSettingsCategory category =
SiteSettingsCategory.fromContentSettingsType(contentType);
if (category != null && !category.enabledInAndroid(getActivity())) {
listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity()));
listPreference.setEnabled(false);
} else {
listPreference.setIcon(ContentSettingsResources.getIcon(contentType));
}
} else {
listPreference.setIcon(
ContentSettingsResources.getDisabledIcon(contentType, getResources()));
}
preference.setSummary("%s");
listPreference.setOnPreferenceChangeListener(this);
}