Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainActivity extends ActionBarActivity {
- private FragmentTabHost mTabHost;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
- getSupportActionBar().setCustomView(R.layout.actionbar_custom); //Ni layout untuk actionbar
- setContentView(R.layout.bottom_tabs);
- mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
- mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
- Bundle b = new Bundle();
- b.putString("key", "Home");
- mTabHost.addTab(mTabHost.newTabSpec("home").setIndicator("Home",getResources().getDrawable(R.drawable.tab_one)),HomeFragment.class, b);
- mTabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#D6D5D6"));
- TextView tv1 = (TextView) mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title); //Unselected Tabs
- tv1.setTextColor(Color.parseColor("#000000"));
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- public void setActionbarTitle(String title) //Panggil method ni kalau nak ubah apa2 kat actionbar, dlm kes ni ubah title
- {
- View v = getSupportActionBar().getCustomView();
- TextView titleTxtView = (TextView) v.findViewById(R.id.actionbar_title);
- titleTxtView.setText(title);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement