Giter VIP home page Giter VIP logo

Comments (21)

JakeWharton avatar JakeWharton commented on July 4, 2024

Can't be done because of method visibility on PreferenceManager and PreferenceScreen.

from actionbarsherlock.

JakeWharton avatar JakeWharton commented on July 4, 2024

This may be possible with a bit of work on second thought...

from actionbarsherlock.

iNoles avatar iNoles commented on July 4, 2024

I have a some idea of this.

PreferenceFragment is just abstract class that extends Fragment that depend on PreferenceActivity.

from actionbarsherlock.

JakeWharton avatar JakeWharton commented on July 4, 2024

I have the beginnings of the class here: https://gist.github.com/1108374

It is based on the decompiled source of Android 3.1. It doesn't compile at present but it's a start. There are a lot of internal APIs in use on the official version of the class. We can't depend on PreferenceActivity so some of these methods will have to have their implementations duplicated. I don't have the time to look at it just yet.

from actionbarsherlock.

JakeWharton avatar JakeWharton commented on July 4, 2024

This is being worked on in a private repo for now. Once it is compiling I'll make it public. It will be at https://github.com/JakeWharton/Android-PreferenceFragment.

from actionbarsherlock.

ChristopheVersieux avatar ChristopheVersieux commented on July 4, 2024

Have you made any progress since Augustus 2010? I would like to set my preference in a ViewPager but that gives me serious headache!

from actionbarsherlock.

JakeWharton avatar JakeWharton commented on July 4, 2024

Haven't touched it since. Working on ABS v4 now. I might try it once that is completed.

from actionbarsherlock.

chrisbanes avatar chrisbanes commented on July 4, 2024

@ChristopheVersieux it shouldn't be too difficult to do it yourself, here's the ICS source for PreferenceFragment

from actionbarsherlock.

JakeWharton avatar JakeWharton commented on July 4, 2024

I believe it uses internal PreferenceManager and PreferenceScreen APIs which is why I gave up on it initially until the sources were available. The tricky part will be ensuring it can still work with things that extend android.preference.Preference. It's not a requirement, but would be great for a proper solution.

from actionbarsherlock.

ChristopheVersieux avatar ChristopheVersieux commented on July 4, 2024

Thank a lot for your help, I found this one in the meanwhile: http://forum.xda-developers.com/showpost.php?p=19719977&postcount=1
With a perfectly working example.

Great job everybody and thank for your quick help.

from actionbarsherlock.

JakeWharton avatar JakeWharton commented on July 4, 2024

Cool. Thanks for the link. That method uses reflection to access the internal APIs so I'll still probably have a go at creating a proper implementation eventually. Glad that works for you for now though.

from actionbarsherlock.

pommedeterresautee avatar pommedeterresautee commented on July 4, 2024

Hi Jake, do you plan to work on it? It s not the most useful class in the world, but it would help to have it :)

from actionbarsherlock.

pc-jkoren avatar pc-jkoren commented on July 4, 2024

Please continue development on this, I beg you.

from actionbarsherlock.

oleg-codaio avatar oleg-codaio commented on July 4, 2024

Yes - I need to use loaders and fragments in preference activity when some items are clicked and cannot!

from actionbarsherlock.

paulpv avatar paulpv commented on July 4, 2024

Here seems to be an impressive Unified solution:
https://github.com/saik0/UnifiedPreference

from actionbarsherlock.

jeancaffou avatar jeancaffou commented on July 4, 2024

@paulpv did you manage to use UnifiedPreference as a SherlockFragment? I am experienceing the following issue:

04-18 03:59:26.000: E/AndroidRuntime(8437): FATAL EXCEPTION: main
04-18 03:59:26.000: E/AndroidRuntime(8437): java.lang.ClassCastException: si.neanonimen.Settings$NetSettingsPrefsFragment cannot be cast to android.support.v4.app.Fragment
04-18 03:59:26.000: E/AndroidRuntime(8437): at android.support.v4.app.Fragment.instantiate(Fragment.java:384)

NetSettingsPrefsFragment extends UnifiedPreferenceFragment

http://stackoverflow.com/questions/16081706/using-preferencefragment-in-sherlockfragmentactivity-with-tabs

from actionbarsherlock.

rovertolonegro avatar rovertolonegro commented on July 4, 2024

Hello, I have this code, and when trying to adapt it for use actionbarsherlock I can not use the getFragmentManager, that I can do?

Change to SherlockPreferenceActivity and actionbar by getSupportActionBar, but getFragmentManager fails me ... Why?

public class Settings extends PreferenceActivity{

@OverRide
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);

ActionBar actionBar = getActionBar();
actionBar.setTitle(R.string.preferencias);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeButtonEnabled(true);
actionBar.setIcon(R.drawable.actionbar_cerrar);

getFragmentManager().beginTransaction().replace(android.R.id.content,
new SettingsFragment()).commit();
}

from actionbarsherlock.

SebastianEngel avatar SebastianEngel commented on July 4, 2024

Hi Jake,

are you still working on this or do you plan to?

from actionbarsherlock.

kolavar avatar kolavar commented on July 4, 2024

I wrote a compatibility layer for PreferenceFragment. Java reflection is used extensively to access private/hidden methods and fields. It's available here:

https://github.com/kolavar/android-support-v4-preferencefragment

from actionbarsherlock.

mszaro avatar mszaro commented on July 4, 2024

@kolavar, your compatibility layer is brilliant, and working perfectly in my app. Thank you so much for the contribution. I have mostly had success using it in combination with ABS by having your PreferenceFragment class extend from SherlockFragment instead of the Fragment class in the support library.

from actionbarsherlock.

3mph4515 avatar 3mph4515 commented on July 4, 2024

@kolavar , yep, compatibility is great! Thank you very much!

from actionbarsherlock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.