How to customize individual tabs? (changing background color, indicator color and text color)

Just set your custom view at the tab creation time, something like: final Tab firstTab = actionBar.newTab() .setText(mAppSectionsPagerAdapter.getPageTitle(0)) .setCustomView(R.id.custom_tab_view_red); final Tab secondTab = actionBar.newTab() .setText(mAppSectionsPagerAdapter.getPageTitle(1)) .setCustomView(R.id.custom_tab_view_blue); // etc actionBar.addTab(firstTab); actionBar.addTab(secondTab); // etc in inCreate(). You’ll also have to define Views corresponding to the above ids in your xml layout file (and not styles). Or, if … Read more

How to handle AsyncTask’s in ActionBarActivity Fragments when ViewPager is used?

The FragmentPagerAdapter keeps additional fragments, besides the one shown, in resumed state. The solution is to implement a custom OnPageChangeListener and create a new method for when the fragment is shown. 1) Create LifecycleManager Interface The interface will have two methods and each ViewPager’s Fragment will implement it. These methods Are as follows: public interface … Read more

How to resolve the error “No resource found that matches the given name” when adding library v7 AppCompat in Eclipse?

This is what you have to do for use the ActionBar support library correctly. Follow the instructions in the Support Library Setup – Adding libraries with resources. One thing that can bring some doubt is add the library to your aplicattion project: (1) In the Project Explorer, right-click your project and select Properties. (2) At … Read more

How to get ActionBar view?

Yep. You can actually get the view by using this function: public View getActionBarView() { Window window = getWindow(); View v = window.getDecorView(); int resId = getResources().getIdentifier(“action_bar_container”, “id”, “android”); return v.findViewById(resId); } Pretty much the way this works is that the actionbar container uses the id android.R.id.action_bar_container, but this id is not public. Therefore we … Read more

Difference between ActionBarSherlock and ActionBar Compatibility

ActionBarSherlock vs ActionBarCompat: I Just want to put few code difference between ActionBarSherlock vs ActionBarCompat Lib We can migrate some apps from ActionBarSherlock to ActionBarCompat: steps: Import AppCompat project. Replace SherlockFragmentActivity with ActionBarActivity. Replace SherlockFragment with Fragment. Change Menu, MenuItem and getSupportMenuInflater() references. Modify the way you get Action Views. mSearchView = (SearchView)MenuItemCompat.getActionView(mSearchItem) Modify your … Read more

MenuItemCompat.getActionView always returns null

Finally I found the solution. Changing namespace of actionViewClass from android:actionViewClass to app:actionViewClass Implementing android.support.v7.widget.SearchView.OnQueryTextListener interface for current activity. Directly use setOnQueryTextListener instead of SearchViewCompat.setOnQueryTextListener @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView != null) { searchView.setOnQueryTextListener(this); } return super.onCreateOptionsMenu(menu); … Read more

Difference between android-support-v7-appcompat and android-support-v4

UPDATE There are many changes done into support library since this question was answered. Good thing is, it is very well documented also. So you must read Support Library Documentation for more details and more available support library. Starting with Support Library release 26.0.0 (July 2017), the minimum supported API level across most support libraries … Read more