android-preferences

Can't set header preference icon via ?attr

旧街凉风 提交于 2019-12-04 11:13:44
I have created preference-headers.xml. I want to set header icon via ?attr , but it doesn't show the icon. <?xml version="1.0" encoding="utf-8"?> <preference-headers xmlns:android="http://schemas.android.com/apk/res/android" > <header android:fragment="com.armsoft.mtrade.activities.PreferencesActivity$PrefsAboutFragment" android:icon="?attr/menuIconAbout" android:title="@string/about" /> </preference-headers> I solved the problem with a mixture of headers.xml and Changing the icon. public void onBuildHeaders(List<Header> target) { this.loadHeadersFromResource(R.xml.pref_headers, target); //

On/Off Toggle Button in Preferences & Action Bar - Ice Cream Sandwich Style

ε祈祈猫儿з 提交于 2019-12-04 10:15:36
问题 I am referring to the blue ON/OFF styling as seen in the default Android Settings app on ICS phones. It can also be seen here: http://android-developers.blogspot.com/2012/02/android-design-v2-now-with-stencils.html I want to put them in a Preference screen, would I have to use a custom preference widget? Also, is it easy to put toggle buttons in the Action Bar? It seems to be possible since it is done for Wifi Settings in the default Android Settings on ICS, but it is probably a custom menu

NullPointerException at android.widget.ArrayAdapter.createViewFromResource

家住魔仙堡 提交于 2019-12-04 05:01:26
I am creating a application with preference activity where the listpreference entries are problematically assigned. This application works fine on my emulator but while i test my application in mobile it shows error like this FATAL EXCEPTION: main java.lang.NullPointerException at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394) at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362) at android.widget.AbsListView.obtainView(AbsListView.java:2033) This problem arises when i click that listpreference in my mobile. here this is my code prference.xml

preferencefragment no view found for id android

雨燕双飞 提交于 2019-12-04 03:03:41
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.Editor m_editor; static Context m_context; int m_order_type_val = 0; boolean m_wreck_selected = false;

How to set a default value to SharedPreferences programmatically?

蓝咒 提交于 2019-12-04 01:46:43
问题 I am using SharedPreferences to keep the information about user's weight, which I need in my application. The problem is, how to set a default value (eg. 75 kg) automatically after installation? I know how to do it via .xml, but how to do this programmatically? My code: public class SettingsDialogFragment extends DialogFragment{ public static final String PREFS_NAME = "settings"; public Dialog onCreateDialog(Bundle savedInstanceState) { builder.setPositiveButton(R.string.save, new

What is the file name used by default shared preferences?

巧了我就是萌 提交于 2019-12-03 23:35:55
Android Backup Service requires a filename to backup shared preferences: public static final String PREFS = "PrefFile"; SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, PREFS); It is clear what to use if filename is given during preferences creation like public static final String PREF_FILE_NAME = "PrefFile"; SharedPreferences preferences = getSharedPreferences(PREF_FILE_NAME, MODE_PRIVATE); But I use default shared preferences: SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); What should I pass as PREFS value to

Custom preference not clickable

梦想的初衷 提交于 2019-12-03 21:17:57
I added a custom preference to my project (code below). I added it to my preferences xml with a custom widgetLayout: <w.PlusOnePreference android:title="Rate App" android:key="custom" android:widgetLayout="@layout/plusone_pref"/> Preference layout xml: <?xml version="1.0" encoding="utf-8"?> <com.google.android.gms.plus.PlusOneButton xmlns:android="http://schemas.android.com/apk/res/android" xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus" android:id="@+id/plus_one_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity=

Add a Button into PrefrenceScreen : Android

非 Y 不嫁゛ 提交于 2019-12-03 20:32:35
Hi i want to add a button into prefrencescreen, i got success into add a button into the prefrence but i could not get onClick event. i have attached my code a pic of prefence screen setting.xml <PreferenceCategory android:title="Application Details"> <Preference android:key="type" android:title="Type" android:summary="" /> </PreferenceCategory> <PreferenceCategory android:title="Notification Settings"> <ListPreference android:key="sendNotificationType" android:title="Status Notification For" android:dialogTitle="Status Notification For" /> </PreferenceCategory> settingdetail.xml <TextView

Apply tint to PreferenceActivity widgets with AppCompat v21

妖精的绣舞 提交于 2019-12-03 18:26:16
问题 I'm using CheckboxPreference in a PreferenceActivity and an AppCompat theme from the v21 support library. As you already know, with this latest library widgets like checkboxes, editTexts, radio buttons etc are tinted with the secondary color defined in the theme. In the preference screen, text is in the right color as specifified by my theme, but checkboxes and edittext are not. It seems that when the CheckboxPreference instance creates the widget, it doesn't apply my theme to it. Radio

Multi select ListPreference on android

寵の児 提交于 2019-12-03 17:52:30
问题 Any idea on implementing a multi-select (check boxes) ListPreference on Android? Would I have to extend the ListPreference? Is there any classes already documented to do this? Thanks 回答1: Multi select ListPreference now comes natively with Android from API level 11 (Honeycomb). http://developer.android.com/reference/android/preference/MultiSelectListPreference.html Because it will be quite a while before devices have Honeycomb or later installed I'd recommend people to stick with the http:/