android-preferences

Start Activity from preference screen (intent defined in xml file)

给你一囗甜甜゛ 提交于 2019-12-18 14:50:11
问题 In my preference file I go this <PreferenceCategory android:title="Title" > <Preference android:title="title" > <intent android:action="com.my.package.MainActivity" /> </Preference> </PreferenceCategory> The activity is created in the manifest file , but I still get android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.my.package.MainActivity } How can I start activity from preferences screen ? 回答1: I had the same issue but none of the solutions i searched on

How to add toolbars to AppCompatPreferenceActivity?

别说谁变了你拦得住时间么 提交于 2019-12-18 12:59:21
问题 I'm trying to add toolbars to the AppCompatPreferenceActivity but I don't know how to do so. Can you tell me how? 回答1: First copy AppCompatPreferenceActivity to your project. The use it like this: public class SettingsActivity extends AppCompatPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupActionBar(); } private void setupActionBar() { Toolbar toolbar; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM

How to right align PreferencesActivity in android?

余生长醉 提交于 2019-12-18 12:58:09
问题 I have PreferencesActivity which I need it to be right aligned because I want to use Arabic language, I tried to use android:layout_gravity="right" for PreferenceScreen but it didn't work. This is my XML: <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:layout_gravity="right"> <PreferenceCategory android:title="General Settings"> <CheckBoxPreference android:title="Full Screen" android:defaultValue="false" android:summary="Always view as Full Screen" android

HowTo use support.v7.preference with AppCompat and potential drawbacks

南楼画角 提交于 2019-12-18 10:24:31
问题 I was trying to implement preferences for an AppCompat app, using support.v7.preference. It took me a couple of days to fiddle through it, since support.v7.preference has some significant differences to the native preferences... which isn't too bad once you know, but unfortunately there's little documentation out there. I thought I'd share my findings so others don't have to go through the same pain. So... question: How do you best implement Preferences for AppCompat apps (with

How to get all keys of SharedPreferences programmatically in Android?

大城市里の小女人 提交于 2019-12-18 10:12:16
问题 How to get all keys in SharedPreferences , not the value of the preference just key only? prefA = getSharedPreferences("MyAttack", MODE_PRIVATE); prefB= getSharedPreferences("MySkill", MODE_PRIVATE); 回答1: SharedPreferences has the method getAll() that returns a Map<String, ?> . From the Map you can retrieve easily the keys with keySet() and the key/value mappings with entrySet() : Map<String, ?> allEntries = prefA.getAll(); for (Map.Entry<String, ?> entry : allEntries.entrySet()) { Log.d("map

How to get all keys of SharedPreferences programmatically in Android?

别等时光非礼了梦想. 提交于 2019-12-18 10:10:14
问题 How to get all keys in SharedPreferences , not the value of the preference just key only? prefA = getSharedPreferences("MyAttack", MODE_PRIVATE); prefB= getSharedPreferences("MySkill", MODE_PRIVATE); 回答1: SharedPreferences has the method getAll() that returns a Map<String, ?> . From the Map you can retrieve easily the keys with keySet() and the key/value mappings with entrySet() : Map<String, ?> allEntries = prefA.getAll(); for (Map.Entry<String, ?> entry : allEntries.entrySet()) { Log.d("map

Initialize preferences from XML in the main Activity [duplicate]

蹲街弑〆低调 提交于 2019-12-18 10:04:09
问题 This question already has answers here : Android Preferences: How to load the default values when the user hasn't used the preferences-screen? (5 answers) Closed 6 years ago . My problem is that when I start application and user didn't open my PreferenceActivity so when I retrieve them don't get any default values defined in my preference.xml file. preference.xml file: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android

Initialize preferences from XML in the main Activity [duplicate]

半城伤御伤魂 提交于 2019-12-18 10:02:37
问题 This question already has answers here : Android Preferences: How to load the default values when the user hasn't used the preferences-screen? (5 answers) Closed 6 years ago . My problem is that when I start application and user didn't open my PreferenceActivity so when I retrieve them don't get any default values defined in my preference.xml file. preference.xml file: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android

Custom PreferenceScreen with clickable buttons

 ̄綄美尐妖づ 提交于 2019-12-18 08:51:38
问题 I have created following Custom Preference Screen. I want to add Listener on Button1 and Button2. How should I do it? I am using following code for creating above Preference Screen. DemoPref: import android.app.Activity; import android.content.Intent; import android.os.Bundle; public class DemoPref extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);

Erros in trying to synchronize Eclipse workspace files across a Windows machine and an Ubuntu machine; which files must or must not be included?

走远了吗. 提交于 2019-12-18 07:07:04
问题 I have been developing an Android app on a Windows machine. Now I would like to continue development on another Ubuntu 10.04 LTS machine. I would like to move between computers maintaining a recent copy of the project files on each computer. I am using SpiderOak to create a synchronization of the workspace directories of Eclipse which I am using for development. When the files were copied from the Windows machine onto the Ubuntu machine and I ran Eclipse, an error was presented that the path