I'm writing an application. It needs to run on old android OS's to be useful. I have written the preferences screen using a PreferencesActivity that populates with a options.xml file that contains PreferenceScreen. It has no submenu for preferences (so PreferenceFragment provides no real benefits).
In Android 2.1 (2.2 and 2.3, haven't tested on ICS yet) the screen displays properly like so in landscape:
But on Jellybean, it looks like this:
It looks terrible. I have nothing defined as a layout, just standard addPreferencesFromResource(). Does anyone know what the cause of this might be? Or a solution?
My onCreate looks like this:
protected void onCreate(Bundle savedInstanceState) { //
super.onCreate(savedInstanceState);
Log.i(TAG, "Options Activity Loaded.");
setTitle(getString(R.string.optionsTitle));
addPreferencesFromResource(R.xml.options);
setupListeners();
}
Everything else just makes Preference objects and assigns methods to do stuff when they get clicked. I don't want to make code for both PreferenceFragment and PreferenceActivity. I do not understand how google expects us to use Fragment APIs if the largest version marketshare doesn't have that API and they will not add it to the compatibility lib.
Your application can support both the old and the new functionality for SharedPreferences. You can provide a Class for the old preferences and a Class for the new. Its not much more code. You can make your app backward compatible like this:
Class spc = Build.VERSION_SDK_INT < Build.VERSION_CODES.HONEYCOMB ?
oldPreferenceActivity.class : newFragmentPreferenceActivity.class;
Intent i = new Intent (this, spc);
startActivityForResult (i, SHOW_PREFERENCES);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With