您好我正在开发一个Android应用程序,我需要将drawable设置为操作栏Tabs
,就像屏幕截图一样。我没有在Tab
上找到任何方法来设置drawable。请帮助我实现这一目标。
public class PayStubActivity extends ActionBarActivity implements ActionBar.TabListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pay_stub);
// adding action bar tabs to the activity
ActionBar mActionBar = getSupportActionBar();
Tab firstTab = mActionBar.newTab().setText(getString(R.string.paystub_current_tab)).setTabListener(this);
Tab secondTab = mActionBar.newTab().setText(getString(R.string.paystub_all_tab)).setTabListener(this);
// add the tabs to the action bar
mActionBar.addTab(firstTab);
mActionBar.addTab(secondTab);
// set the navigation mode the Action Bar Tabs
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction fragmentTransaction) {
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction fragmentTransaction) {
// user is selected first tab
if(tab.getPosition() == 0) {
fragmentTransaction.replace(R.id.container, new CurrentPayStubFragment());
} else {
// user is selected second tab.
}
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction fragmentTransaction) {}
}
提前致谢。