I want to support api level 9 and still using fragments and tabs. Therefor I have used sherlock action bar and it works fine. Now, in one of my tabs (all tabs are fragments) I want to have a settings screen for creating a new game. I figure preferences is the best choice. BUT I don't know how to use preferences in a fragment and still support api level 9. Can anyone please help?
If it's not possible to use preferences in fragment and support api level 9, do you have any suggestions? How can I for example create views to look like a preference, that is, text to the left, checkbox to the right and when I check it, the whole layout gets selected? And a radiobuttongroup with the same look?
Related
Working on Worklight project for Android platform. Wondering is there any way to override WL.OptionsMenu.addItem?
This is not to hide settings option menu. From Android SDK 11, option menu will be replaced with action bar. In full screen of WebView there is no way to show action bar. In this mobile app, implemented sliding menu. Each time invoke WL.OptionsMenu.addItem will add a menu item in sliding menu.
Thanks
Based on your edit:
Worklight does not yet support the ActionBar in Android, so oddities can happen when using the WL.OptionsMenu API in conjunction with API Level 11 in Android.
Can you explain what you're trying to accomplish? What does "overriding" an item mean in your case?
This is the WL.OptionsMenu API, you can do whatever you want in its limits.
If you mean that you'd like to simply remove the default "Worklight Settings" item, then you need to set worklightSettings to 'false' in application-descriptor.xml. After that, you can simply initialize the OptionsMenu and add any items you need to it.
If you mean that you have an existing item you would like to change, since you know the item ID, you can simply re-create the item, which essentially overrides what it was previously doing.
I've been trying to setup a ViewPager with tabs in the ActionBar, but I also wanted to support older API levels (pre-ActionBar levels).
Since nearly everything that I'm trying to do in order to setup the tabbed ViewPager requires API level 11 and I can only seem to get the support libraries to go so far, I'm unsure as to what I should do.
I know I could use a TabWidget with a HorizontalScrollView to get the job done, however I don't think it will be efficient enough, nor provide the same user experience/usability/interaction, right?
or
Should I use the Sherlock Action Bar?
Sherlock Action Bar is recommended for using ActionBar in API < 4.0 not only for ViewPager movements it provides navigation like "Up" button and actionItems behaviour also if you need to in future migrate the app to support apis >= 4.0 the changes are very very little.
I'm having a bit of a problem with the Android tab layout. I've been trying to make a screen that holds 4 tabs, and a fragment beneath them, when a user presses each tab the fragment dynamically switches to another activity and the tabs stay static, my problem is that I tried to implement it with tab layout and it's deprecated in since Android 4.0, so I tried it with the action bar tabs but then I have the action bar that I don't want nor need.
I have two questions:
Is it possible to use action bar but to hide the action bar and show only the tabs?
Is there a way to use tab layout on Android 4.0 and higher versions?
1.Yes there is possibility.....you should try http://actionbarsherlock.com/
2.ActionBarSherlock works from sdk 7 to sdk 16
I am not really sure about whether you can achieve it or not but if you want to play around with the ActionBar, this would be one of the best places to start.
Just because it is deprecated, doesn't mean that you can't use tabs in Android 4+. ;)
You surely can use Tabs and TabLayout in Android 4+ and everything works perfectly(though you apparently should not as ActionBar is a must better option).
I have tried it myself because even I prefer the TabLayout more than the ActionBar, and thankfully haven't run into any issues until now!
The only thing you will notice is that Eclipse will draw a yellow line over the deprecated code (which you can obviously ignore or just choose to hide all deprecated warnings).
I want to create a app with a menu at the bottom of the screen. This menu should be visible any time the app is started.
Im working with fragments, so the menu is one fragment.
So I have only one Activity as controller which loads different fragments above the menu fragment.
Because I want to create clean code, i dont know how to solve the problem that the Activity class is too big.
In other words, i want to create different controller within the same activity. How to do that?
Is there another approach to solve this issue?
You should be using the split action bar This allows you to put the Actions and overflow menu on the bottom of the screen. I believe you can use Action Bar Sherlock for backwards compatibility to older versions of Android. See their site for detail.
Another possibility is to look into using fragments with the ViewPager . Here is a library that works with compatability as well ViewPageIndicator . Here is a blog post , like I indicated in my comment I got this working with the tabs showing at the bottom and the pages above.
I'm building an application that requires Tabs, which are now deprecated. The dev guide says to use Fragments to replace the tabs instead. However, my application needs to have fragments within each tab, which means fragments inside fragments, which isn't allowed. Does anyone know of a possible work around for this?
While the action bar support for tabs is designed to make it easy for the contents of a tab to be a fragment, that is not strictly required. You could use ViewFlipper, repeated calls to setContentView(), or something to arrange to change other stuff when the action bar tab is selected.
Prior to the native action bar (Android 1.x/2.x), either stick with classic tabs, or use something like Action Bar Sherlock to get an action bar and tabs.
I fake tabs by having a "tabs" fragment across the top that contains multiple toggle buttons. Below that I have a merge view containing a separate fragment for each tab.
I respond to taps on a toggle button by toggling the other buttons "off", showing the fragment for that "tab", and hiding the others.
its little late , but yes you can :) here's an example
but for fragment inside fragment inside tab isn't an android native way, you have to start a new fragmentActivity if you want to show detail of fragment. you can but is not an android way !