Showing posts with label Tab. Show all posts
Showing posts with label Tab. Show all posts

Thursday, July 25, 2013

Android Action Bar backward compatibility support in lower version of android O.S

While following android design patterns, Action bar is an important factor in it. Unfortunately Action bar was not supported in lower version than 3.0. Which was very painful for developer because still android 2.3.3 has fair amount of share in android market. So developers were forced to use Sherlock ActionBar and others
But Good news is , we no more need to rely on third party library for support of Action Bar in lower version from July 2013.
Google Android has provided their native support for backward android version as part of new latest update.
Even Though i  have not gone through this API but seems very very helpful.

Android Support Library, revision 18 (July 2013)


This library will remove the developer pain of Action bar support. I feels that because of its limited support developer can not use Action Bar in latest version also. As using Action Bar and third party Action Bar was very hectic and it lead to great effort with no good result.
Upto now We should thank Sherlock Actionbar. They made one excellent productive library

Soon i am going to post of using this library in our own application. 

Sunday, September 2, 2012

Action Bar with Tab in android

In android latest version, TabLayout had deprecated because of its some constraint. Now we Action bar that mainly replace Menu in recent version. Most importantly we can use action bar as replacement of TabLayout also.

For using Action Bar, we need to use getActionBar(); method that will return action bar object. even you can use Menu xml to create a Action Bar but here i am creating Action Bar dynamically.

 ActionBar bar = getActionBar();  
bar.addTab(bar.newTab().setText("Tab 1").setTabListener(this));
bar.addTab(bar.newTab().setText("Tab 2").setTabListener(this));
bar.addTab(bar.newTab().setText("Tab 3").setTabListener(this));
bar.addTab(bar.newTab().setText("Tab 4").setTabListener(this));
bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM
| ActionBar.DISPLAY_USE_LOGO);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayShowHomeEnabled(true);
bar.setDisplayShowTitleEnabled(false);
bar.show();

you can hide Action bar if you want 

 bar.hide()  

The we can perform and detect action state of action bar tab by implementing TabListener .So out of final code will be like this
Action with tab
Action Bar with Tab
                                               
But this source will run only the version from 3.0
                                                                  Download Source Code

Posting Lama ►
 

Copyright 2013 Tutorials For Newbie: Tab Template by CB Blogger Template. Powered by Blogger