I want to display a main menu on the left and a settings page on the right of the screen. I want to use the Android compatibility API and fragments.
I also want to make use of the Android preferences features and add the preferences from .xml file, and don't want to use workarounds (like personally customized list views, linear layouts, etc). What options do I have, considering that PreferenceFragment is not included in the compatibility API?
Try using ActionBarSherlock's PreferenceActivity plugin.
Here is the sample source code.
Related
I used to have a PreferenceActivity in Android but then I wanted to migrate to AndroidX.
Now I can't find any solution to have this kind of preference grouping:
I have tried:
PreferenceCategory (but it doesn't groups preferences into deeper levels, just visually breaks them)
PreferenceScreen (before AndroidX it used to work, but now it just display the main settings /General, Notifications, Data & Sync/ but I cannot go deeper.)
PreferenceGroup (but it is abstract and I have no idea how shall I implement, or shall it work at all)
Do you have any idea on how can I get the above functionality with AndroidX Preference library?
(androidx.preference:preference:1.1.0).
You should use a separate PreferenceFragmentCompat per sub-screen, see the Settings Guide for more information.
Is there an easy way to create a preference like the system preferences in Lollipop?
My previous app had headers and fragments, but I want to use the AppCompat Toolbar and the PreferenceActivity (onBuildHeaders) can't use the new Toolbar. That's why I'm searching for a complete redesign of my preferences.
I want to do this:
Has someone any tutorial for this?
It' s simple. Just apply the Theme.AppCompat.xxx to your activity and put your PreferenceFragment in that activity if you use the Api level >= 11.
EDIT
for the lastest supoort libary appcompat-v7, google provides AppCompatDelegate to do the trick, here is the sample code from google.
Try out my library: https://github.com/AndroidDeveloperLB/MaterialPreferenceLibrary .
It lacks some of the stuff of the original API, but it's a good start... The hard part is to make it use a RecyclerView instead of a ListView, so that you could have multiple preferences on the same row. Then you'd need to also filter items as you type.
I have an existing app that is using a Dashboard style pattern where there's a main menu, and clicking icons on the main menu drive start different activities... In order to navigate to a different function, you need to go back to the Dashboard menu and select another icon.
I want to change my application to a tabbed format similar to the one below with Icons:
What type of View is being used below? Is this a FragmentActivity? Also, what is the best approach to go about conversion? I have a bunch of layouts with listviews in linear/relative layouts... Will I be able to reuse any existing code? I want also to be able to use the solution with Android 2.1 and up if possible.
Thanks!
In the image you provided, it looks to be a TabHost that is used (which can be within a normal Activity or a Fragment Activity) and will be available for Android 2.1 and beyond when using the Android Support library. Based upon your description, you most likely have an Activity per each of your items that you will probably want to convert into a different Fragment. This may take a little time, but a Fragment is very similar to a normal activity in many ways, so once you start getting used to it, converting over the old Activities should be a breeze.
If you plan on using these tabs and you follow the Android design UI guidelines, you may want to use the TabHost in conjunction with a ViewPager. There is a great tutorial for this online that also allows for backward compatibility (down to at least 2.1) found here: http://thepseudocoder.wordpress.com/2011/10/13/android-tabs-viewpager-swipe-able-tabs-ftw/
Support library for fragments/viewpager: http://developer.android.com/tools/extras/support-library.html
More info about a TabHost and using Tabs with fragments can be found here:
http://developer.android.com/reference/android/widget/TabHost.html
http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/
You can use TabLayout and a TabActivity to achieve layout in picture. Bad news is these are deprecated as of Android 3.0. Google advises to use fragments instead of these.
I want to show my activities inside of a running activity. I need something like frame in html language that is used for showing other pages inside a page. I know Tabhost has this ability. Which one of other controls has this ability?
Thanks,
Google introduced fragments in Android 3.0 and upper to create a portion of user interface in an Activity. But it is not two Activity, becuase activity <> window. For lower version you can manually load xml layout in your activity.
The Fragment API is really your best choice, it's quite easy to use and you can dynamicly add them to your Activity Layout (take a look to Framgent For All - google Article) by code using the FragmentManager, this feature it's since 3.0 altough Google also released a pretty nice Compatibility Package that you can download out of the SDK Manager and added to your project like this Fragment For All:
I am working on android app where I am thinking to develop reusable UI interface. How it can be developed and included in my .xml's
Here I want to develop a progress bar with my image and it will be display on some .xml's.
Please provide any code help.
I am a new in this field.
you can use <Include> xml tag within your layout xml,
read this :)
http://developer.android.com/resources/articles/layout-tricks-merge.html
I think you need to use styles and themes. Check this out.
You can either build custom (compound) views, look at Building Custom Components.
Or you can use Fragments. Fragments are new in Honeycomb (Android 3.0), but there is a compatibility library that adds fragment support to lower android versions (can be found in your ANDROID_SDK/extras/android folder). Or you can mix both of course.