preferenceactivity

setHomeButtonEnabled on PreferenceActivity and nested preference

给你一囗甜甜゛ 提交于 2019-12-06 00:30:35
问题 I have preference screen extended PreferenceActivity . For targeting OS 4.0.3, I wanted to add < icon on action bar so I did this in onCreate() . ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); It worked. < was added to left of app icon. But when I tap the item which goes into the next level (more detail screen), the < won't be displayed. Returning to the top level, the < appears again. I have never thought about a

EditTextPreference.setText(value) not updating as expected

≡放荡痞女 提交于 2019-12-06 00:08:44
I'm trying to prevent the user from entering an empty string into an EditTextPreference (in the example, catName ). I use a OnPreferenceChangeListener to detect when a change is made to the EditTextPreference , and if there is a change and the string is blank, I use the EditTextPreference.setText() command to reset to the old value. However, the new value doesn't show up properly if I reopen the EditTextPreference in the GUI (the string is blank), and if I go back into the main app, I can verify that a blank value is being saved to the preferences. I've verified that the if statement executes

Android开发之--Preferences的使用

限于喜欢 提交于 2019-12-05 22:10:41
在android程序中,记录用户的偏好是个能极大提升用户体验的功能。Android里面的Preferences正式为此事而生。 Preferences可以用来记录简单的整数,布尔值,字符串等数据,且在各个Activity之间均能访问,主要用来实现程序的参数设置功能。最简单的用法是写两行代码自己创建,如下: //从应用的任意处获得Preferences SharedPreferences mPerferences = PreferenceManager .getDefaultSharedPreferences(this); //从Preferences中获得一个值,如果不存在则值为null String loginName = mPerferences.getInt("name", null); if(loginName == null){ Log.v("Preferences", "User not login"); } //获得Editor编辑Preferences的值 SharedPreferences.Editor mEditor = mPerferences.edit(); mEditor.putInt("name", "admin"); //将更新后的值提交 mEditor.commit(); 通过这种方式,应用会在自己的数据文件夹下新建一个名为 shared

preferencefragment no view found for id android

霸气de小男生 提交于 2019-12-05 21:54:29
问题 I had the getpreferencescreen deprecated so I tryed to implement the header preference activity. here is my code: public class EditPreferences extends PreferenceActivity { ListPreference m_list_preference_dive_centre_rating; ListPreference m_list_preference_dive_region_rating; ListPreference m_list_preference_wreck; ListPreference m_list_preference_cave; MultyChoiceListPlugin m_list_preference_marine_life; ListPreference m_list_preference_region; Preference m_order_by_name; SharedPreferences

Android Preferenceactivity getView

半腔热情 提交于 2019-12-05 21:47:26
I have such piece of code :) And i want to edit text property of my custom preference layout. But any changes made on object from getView function does not affect actual list in preference screen. any ideas? I know that i cant extend PreferenceScreen, and i cant use any other type of preference in this case, i only want to be able to edit my custom textview from my layout in code. PreferenceScreen settings = getPreferenceManager().createPreferenceScreen(this); settings.setLayoutResource(R.layout.mypreference); View test = (View) settings.getView(null,getListView()); TextView text = (TextView

Android PreferenceActivity to create a MODE_WORLD_WRITEABLE preference across applications

独自空忆成欢 提交于 2019-12-05 21:29:25
I have multiple applications that share certain data through preferences. Each app sets its preferences through a PreferenceActitivity (from xml). Two questions: How do I use/edit preferences created by one app in another app. If I figure out how to create MODE_WORLD_WRITEABLE preferences using PreferenceActivity that will solve the problem. SharedPreferences prefs = getSharedPreferences( <String referring to another package´s prefs>, MODE_WORLD_WRITEABLE); HashMap<String, String> map = (HashMap<String, String>) prefs .getAll(); String str = map.toString(); tv.setText(str); Above code returns

Start/Stop service by checking/unchecking CheckBoxPreference

╄→гoц情女王★ 提交于 2019-12-05 21:25:37
i'm writting an app that start or stop service by checking or unchecking CheckBoxPreference i tried to find some information such as sample code or tutorials. but i didn'f find yet. how to start or stop service by checking or unchecking CheckBoxPreference which is in PreferenceActivity ? i want to start service when "service_toggle" key is true and stop service when "service_toggle" key is false Are there any sample code or tutorial about Start/Stop service by checking/unchecking CheckBoxPreference ? Here is my code : Settings.java package kr.hybdms.sidepanel; import android.content.Intent;

Is possible to change the summary of EditTextPreference dynamically in Android?

梦想与她 提交于 2019-12-05 13:33:19
I set up a preferenceScreen to edit the settings in my application. I would like to insert an EditTextPreference that contains a Title like "set your name" and a summary containing the name entered. Is that possible? thank you in advance! Sure, here is a short example: EditTextPreference etp = (EditTextPreference) findPreference("the_pref_key"); etp.setSummary("New summary"); This requires that you display your preferences either from a PreferenceActivity or from a PreferenceFragment , since findPreference() is a method of these classes. You most likely do that already. To change the summary

How to get elements(findViewById) for a layout which is dynamically loaded(setView) in a dialog?

假如想象 提交于 2019-12-05 12:41:12
问题 I need to get the EditText that's defined in an xml layout which is dynamically loaded as a view in a preference dialog i.e. : public class ReportBugPreference extends EditTextPreference { @Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); builder.setView(LayoutInflater.from(ctx).inflate(R.layout.preference_report_bug_layout,null)); EditText edttxtBugDesc = (EditText) findViewById(R.id.bug_description_edittext); // NOT WORKING

How to load the same screen preference in the detail PreferenceFragment

﹥>﹥吖頭↗ 提交于 2019-12-05 04:51:38
I am trying to do something like the settings preferences in android for tablet. When I click the "More" the the "Wireless & Networks" preferences screen is displayed on the right fragment, than if I touch the "VPN" , in the same fragment the "VPN" preferences screen is opened. How can I do that ? this is my preference xml <PreferenceScreen android:title="Title A"> <PreferenceScreen android:title="TITLE B"> <PreferenceCategory android:title="category"> <ListPreference android:key="list" android:title="list" android:entries="@array/list_vals" android:entryValues="@array/list_vals1" android