Android tab layout issue - android

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).

Related

3 dot/settings in top bar buttons

When in some apps, there are those 3 dots in the top right of the app, on the action bar (not the home buttons), which allow for more options. In my app I have on, but I do not know how to make it do a method when it is clicked. Do I use android:onClick="METHOD_NAME ? Or do I need to setup a button variable in my activity class and setup and onClickListener? I have already tried both but I may be doing something wrong.
That three dots are the menu in the action bar. They are always shown on devices without a menu key.
See also the documentation for more details.
Three dots are called Overflow(very aptly named) and to use them you need to use ActionBar which is the top long, horizontal bar showing icons, other buttons along with the Overflow button.
Now in some devices where there is no physical menu button you will always see Overflow button.
Go through Docs and tutorials related to ActionBar but keep one thing in mind that ActionBar is only available for devices with android above HoneyComb. For android devices below 3.0 such as GingerBread or Froyo you will have to use compatibility libraries, so that will be an additional task.
And most notable libraries for this purpose are ActionBarSherlock and AppCompat.

How to use preferences in fragment using sherlock action bar

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?

ActionBarSherlock tab height not adjustable on Jelly Bean

I am creating an application with ActionBarSherlock and using ActionBar tabs. Below is how I am defining tabs:
actionBar.addTab(actionBar.newTab().setText("test").setTabListener(new TabListener<AccountsListFragment>(this, "accounts",AccountsListFragment.class)));
I am trying to change the height of the tabs. From what I understand there is no way to change just the height of the tabs. You also have to change the height of the main action bar(I am pulling my definition of the main action bar from)
http://developer.android.com/design/patterns/actionbar.html#considerations-split-action-bars
So how you change the height of the action bar is using the below style inside the main theme
<item name="actionBarSize">100dp</item>
<item name="android:actionBarSize">100dp</item>
The above code seems to work on all devices to change both the Main action bar and the tabs except jellybean. I tested this on a 4.1.2 galaxy nexus. Also on a 4.2 Nexus 7. It seems to work the same on both. It only changes the main action bar and not the tab height at all.
We also tried a custom view for the tabs which did not help us.
If anyone can point me to where in google it says that they do not allow changing height of tabs anymore(Which I doubt is the case) or give me a style to fix this issue. I would greatly appreciate it. If you even give me an example on a normal action bar and not sherlock that should help me.
To me it sounds like a silent bug fix. They make some of these at every new release. I doesn't make sense that changing the height of the actionbar should increase the size of the tabs and it isn't something that has been encouraged by Google, rather it's a hack developers have found nice to use. Your only other option is to make it yourself, but it's quite complex and could prove to be time consuming.
Similar post here:
Change Actionbar height on Android JellyBean

create app with menu at the bottom (like many iphone apps), how to organize activity / fragments

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.

Creating Android Facebook-like menu on bottom bar

I'm using Galaxy tab and it's got a bar on bottom that appears all the time.
FB app shows a new item there that used as a menu button.
How can I declare my menu to be there like FB?
Thanks!
I guess they are still using the old options menu. You can achieve that effect by setting the target sdk to max 10. I wouldn't recommend that as the menu button hides information and is not the current way to go (I'd use an ActionBar)
You should definately look at the ActionBar. In addition to the tab navigation that is available, you have an option for a split action bar for top and bottom. ActionBar is part of Honeycomb (3.x), but if you want to support older versions, there is the ActionBarSherlock library.

Categories

Resources