EgyRevDev / Arrestred

Repository for Arrested Mobile application
0 stars 0 forks source link

Add ActionBar to Settings Activity on Android API Level 10 or less #1

Open egy-dev-rev opened 10 years ago

egy-dev-rev commented 10 years ago

According to Settings Guidelines provided by Android Developers: I should use PreferenceFragment instead of PreferenceActivity which has been deprecated starting from API Level 11.

But I found out a compilation error upon using PreferenceFragement with Android Support Library 7 as explained in this post (http://stackoverflow.com/questions/15078029/cant-get-the-preferencefragment-to-work-compiling-error)

Since PreferenceFragment is not backport to Support Library, I go for this solution: I would create a PreferenceActivity that uses PreferenceFragment on newer devices and just uses ordinary preference XML on older devices as explained here: https://github.com/commonsguy/cw-omnibus/tree/master/Prefs/FragmentsBC

Accordingly, I have created my own example on this branch () but I faced a critical problem for not being able to get Action Bar instance within a PreferenceActivity as explained here: http://stackoverflow.com/questions/17849193/how-to-add-action-bar-from-support-library-into-preferenceactivity#answer-17877021

So After quick search , I can use unofficial library as answered here: http://stackoverflow.com/questions/9783368/alternatives-to-preferencefragment-with-android-support-v4#answer-20727515

Need to use this unofficial library then test my code against Android API 10 or less.

egy-dev-rev commented 10 years ago

I have used the unofficial library which backports PreferenceFragment til API-4 as indicated in this commit https://github.com/EgyRevDev/Arrestred/commit/0a64548b54c743057746ec7b17b2fd7fd5151a91 I have imported android.support.v4.preference.PreferenceFragment instead of android.preference.PreferenceFragment. It is working fine on Android API 19 (KitKat 4.4) but still needs to be experimented on API 10