I need action bar with custom title bar in android please help me,thanks.
The other option worth looking at is ActionBarCompat, which I think comes with the SDK 14 api demos. However, ActionBarSherlock seems to support many more features so that may be the better solution.
ActionBarSherlock is now kind of a "best practice" you are right in using it.
Create your Menu in the folder with the same name for example :
<item
android:id="@+id/search"
android:actionViewClass="com.actionbarsherlock.widget.SearchView"
android:icon="@android:drawable/ic_menu_search"
android:showAsAction="always|collapseActionView"
android:title="@string/menu_search"/>
<item
android:id="@+id/menu_filtre"
android:orderInCategory="100"
android:showAsAction="always|collapseActionView"
android:title="@string/menu_filtre"/>
<item
android:id="@+id/menu_clear"
android:orderInCategory="100"
android:showAsAction="always|collapseActionView"
android:title="@string/menu_clear"/>
then in your MainActivity for example :
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.clear();
switch ((int) _viewPager.getCurrentItem()) {
case 0:
getSupportMenuInflater().inflate(R.menu.menu, menu);
break;
}
return super.onPrepareOptionsMenu(menu);
}
And to finish :
ActionBar bar = getSupportActionBar();
bar.setTitle(R.string.titre_abs);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
For the installation take a look here http://actionbarsherlock.com/
For creating themes here http://jgilfelt.github.io/android-actionbarstylegenerator/#name=example&compat=holo&theme=light&actionbarstyle=solid&backColor=E4E4E4%2C100&secondaryColor=D6D6D6%2C100&tertiaryColor=F2F2F2%2C100&accentColor=33B5E5%2C100
if you need more just ask
good luck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With