I'm use ActionBar compact in my app and created 2 Tab and Spinner Menu Item. Now I want make change tab indicator by selected item spinner, like this picture :
but i don't know how make it. I just styling in theme with code :
part of Style.xml
<style name="Theme.MyAB" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/ActionBar.Solid</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle</item>
</style>
<style name="ActionBarTabStyle" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_example</item>
</style>
and this part of MyActivity.class where Tab is created
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate our menu from the resources by using the menu inflater.
getMenuInflater().inflate(R.menu.main, menu); ;
MenuItem actionbar_form= menu.findItem(Menus.FORM);
View view1= (View) MenuItemCompat.getActionView(actionbar_form);
if (view1 instanceof Spinner)
{
final Spinner spinner = (Spinner) view1;
spinner.setAdapter(adapterSpinnerMenuForm);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
// TextView txtType= (TextView)spinner.getAdapter().getView(position, null, null).findViewById(R.id.txtType);
Variabel.type= adapterSpinnerMenuForm.spinnerNavItem.get(position).getType();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
}
return true;
}
so how the change indicator tab Actionbar with programatically ? sorry for my english
Hi try this ActionBar Style Generator