Preference Fragment doesn't open in new Preference screen - android

I've been trying to show preference fragment data in a separate preference screen. Tried alot of things but no success. Currently, the data is being displayed on the right half of the screen, while header preferences are visible on the left side:
I want to show the data on full screen:
Thanks in advance!

This guide explains the way to implement what you want.
Basically, you should only have a single PreferenceFragment per PreferenceActivity screen (this toggles a single-pane view); create & call another PreferenceActivity when you want to show another group of preferences.

Related

Opening Fragment From Inside PreferenceScreen

sorry if this is a stupid question.
So, I've got a settings.xml defining my preferences, and at some point in the tree I have:
<PreferenceScreen [...] android:fragment="path.to.fragment" [...] />
And when I tap that thing, I go to my fragment.
That's working.
My fragment is a ListFragment, because I am showing a list of Bluetooth devices on this screen and can't just declare them statically.
My question is, when a user clicks one of the list items in my ListFragment, I want to open a details screen where they can set a preference with that selected device, but I can't figure out how to programatically create and launch this next fragment while still keeping things in the nice tree the preferences provides.
For now I'm just creating an activity so that I can move past that part of the issue, but I have to figure something out before this is done.
Is there an easy way to do this, or am I taking the wrong approach entirely?
Thanks!
EDIT: Picture
So, Page 1 is my settings fragment, which is built using the XML with the highlighted option being generated using PreferenceScreen as above.
Page 2 is my listFragment, and because those items come from Bluetooth, it can't just be another settings xml entry.
Page 3 is what I get when I pick an option (WIP). To get to this point I had to make it an activity and use startActivity, but the other two were fragments. I'm asking if there's a way to programmatically do the same thing the PreferenceScreen option is doing in the xml and launch a fragment with the top bar maintained and stuff.
Alright, here's what I've got.
I realized that at the top level I had a PreferenceActivity, and it has the method startPreferenceFragment.
So, I do:
((PreferenceActivity) getActivity()).startPreferenceFragment(new MyFragment(), true);
Which works for me.
It doesn't feel like a solid solution, but it has the effect I want and I have to move on.

Where to put preference based layout operations in ActionBarActivity

In my app I am creating a custom preference screen. This screen in reached via mainActivity (launcher). The mainActivity also shows the current status of some of these settings by reading them and laying them on views. Now, when the user will reach one of the preference screens and edit them, by design I aim to bring him back to the mainActivity (it would be intuitive to press the back button). This time however I want to show the latest edited settings.
I am used to putting layout operations in onCreate. But, in this case onCreate will only be called once when the activity starts and read the status of preference settings and lay them on screen. However, when he will open a settings activity, edit them and press back button he will not see his latest settings laid on screen as onCreate need not be called.
So, on what activity callback should I place the operations to read preferences and lay them on views.
This is based on my understanding and I may have messed up big time. Guide me, Thanks...
To anyone looking for an answer. Its pretty basic stuff. Create function in your main activity to read preferences and update your views. Now, start your preference activity using startActivityforResult() and when result arrives from that activity, run the same function inside onActivityResult(). Done.

Create a full screen MultiSelectListPreferece

I would like to create a preference screen that is full screen. The screen will contain a multiselect list. It will also be dynamic, i.e. the list on the screen is not static and I would like to have a refresh button. I am going to try and model it after the bluetooth preference screen in android settings (this is not multiselect so mine would have check boxes).
Basically there is some search function that will find list items and populate the list.
Can you create a preference screen (full screen) with a list preference?
or
Can you full screen a ListPreferenceDialog? Problem I see here is that even if I full screen the dialog I would still need to get a bottom action bar for the refresh button.
PreferenceActivity extends ListActivity. So, you can use the underlying ListView and bind a ListAdapter with whatever data you want. But if you want to do things like the Bluetooth settings, take a look at the source. Basically they're calling PreferenceGroup.addPreference each time a new Bluetooth device is found.

Preference with in-line options

I've created a PReference Screen which lets the user manage a series of elements marked by himself as "favorites". I create a Preference category then fill it up with options dynamically, taking them from a sqlite database. This is a screencap:
And this is a screen mockup of what I want to achieve:
That is, I want for every preference item to add an in-line remove option that allows users to directly remove favorites.
The problem is I don't know how to do this, and I've seen no similar examples. Is it even possible?
Android provides an easy means to implement preferences screen, but standard android ListPreference does not provide an easy way to display an image for each item if the list. To add the images to the Android ListPreference, we need to use a custom xml attribute
Here is some example that may help you
http://www.cmwmobile.com/index.php?option=com_content&view=article&id=4&Itemid=12
How to add icons to Preference
To delete prefrence from prefrence screen you you can refer this Link : How to determine which preference item from custom layout button click

How to navigate back through Android preferences programmaticaly?

I have several preference screens. When user click on preference named log-of - I have to disable and hide some preference screens. Because of disabled preferences I need to go one level up in screen preferences hierarchy.
Looking for valuable suggestion.
Thanks.
I decomposed preference hierarhy.
Now have 3 different xml layouts for each preference screen.
When user click 'logof' - I make change in app data and call finish activity. This returns me one level up :) This way causes more code, but logic is clear now.

Categories

Resources