preferenceactivity

setHomeButtonEnabled on PreferenceActivity and nested preference

亡梦爱人 提交于 2019-12-04 07:50:59
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 mechanism of nested preference since smart the PreferenceActivity hides it. Now my question is, why won't

Android: “BadTokenException: Unable to add window; is your activity running?” at showing dialog in PreferenceActivity

不想你离开。 提交于 2019-12-04 07:44:29
问题 I'd like to ask for some help: In my app, I have only one activity, a PreferenceActivity (don't need other, it's just a simple background-sync app, so the PrefsActivity is the Main/Launcher). After the user setup preferences, checks a checkBoxPreference , and that starts (or stops) a service. At starting, a dialog shows. But here is the problem: if the user press back (leave the activity), start it again, and than tries to check the checkBoxPref ., the prefsactivity crashes. Dialog doesn't

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;

Why does Kit Kat require the use of the isValidFragment?

狂风中的少年 提交于 2019-12-04 02:30:40
Ever since KitKat was released, I've noticed a whole bunch of my apps updating with "Fixing a crash in Kit Kat". Recently when I released my own app, I figured out the likely source of that is the new "isValidFragment" requirement for using preference activities. I haven't been able to get anyone, however, to explain why this new class is suddenly needed to validate fragments. Can anyone offer me an explanation of why this is required? Subclasses should override this method and verify that the given fragment is a valid type to be attached to this activity. The default implementation returns

Android set background color of preference category

只谈情不闲聊 提交于 2019-12-04 01:32:46
问题 I try to customize the background color of preference categories. I already changed the background color of a preferences itself but I can't find a way how to change the the categories background color. I found two ways but they don't works for me: changing the preference category label color background Through this link, i found this, but nothing I've tried worked for me. These layout snippet is what I've tried so far: <resources> <style name="setBackgroundTheme" parent="android:Theme">

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

孤街浪徒 提交于 2019-12-03 23:51:51
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 } } EDIT : SOLUTION by jjnFord @Override protected void onPrepareDialogBuilder(AlertDialog.Builder

Google Play services resources were not found. 'AdsMob'

前提是你 提交于 2019-12-03 22:07:12
I am getting this error when I try to load and InterstitialAd from google AdMob. I know that I have written the code correctly. As I followed the short tutorial on https://developers.google.com/mobile-ads-sdk/docs/admob/advanced#play All the happens is I get and error in the Logcat. What might I be doing wrong. Here is the code: public class Pref extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener { /** The view to show the ad. */ private AdView adView; /* Your ad unit id. Replace with your actual ad unit id. */ private static final String AD_UNIT_ID = "MY

Keep the actionbar displayed in when changing PreferenceScreen

落爺英雄遲暮 提交于 2019-12-03 11:16:56
问题 I'm trying to display a actionbar in my preference screen. In order to do so I added the following code in my SettingActivity public class PreferencesActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.preferences_activity); getFragmentManager().beginTransaction() .replace(R.id.container, new PreferencesFragment()).commit(); getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW

Android - Headers categories in PreferenceActivity with PreferenceFragment

扶醉桌前 提交于 2019-12-03 08:42:38
I would like to display a preference screen like the one in the Android settings app : using headers, PreferenceActivity, PreferenceFragment and headers categories. I wan't this result on a tablet : And this one on a smartphone : It works if I just use the basic headers, but if I try to add categories, it works on the smartphone, and crash on the tablet, where I get the exception "java.lang.NullPointerException: name == null" : FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{fr.ifremer.testandroid/fr.ifremer.testandroid.models.preferences