Guest User

Untitled

a guest
Jan 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. tabHost.newTabSpec("name").setIndicator(R.id.your_view)
  2.  
  3. private void fillTabHost() {
  4.  
  5. setupTab(ONE, new Intent().setClass(this, Activity.class), "title",R.drawable.icon);
  6. setupTab(TWO, new Intent().setClass(this, Activity.class), "title", R.drawable.icon);
  7. setupTab(THREE, new Intent().setClass(this, Activity.class), "title",R.drawable.icon);
  8. setupTab(FOUR, new Intent().setClass(this, Activity.class), "title",R.drawable.icon);
  9. setupTab(FIVE, new Intent().setClass(this, Activity.class), "title",R.drawable.icon);
  10. }
  11.  
  12. private void setupTab(final String tag, Intent intent, int label, int icon) {
  13. View tabview = createTabView(tag, mContext, label, icon);
  14. TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(intent);
  15. mTabHost.addTab(setContent);
  16. }
  17.  
  18. private static View createTabView(String tag, final Context context, final int text, final int icon) {
  19. if(tag.equals("THREE")){
  20. // TODO return your CAMERA view
  21. }else{
  22. View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
  23. ImageView iv = (ImageView) view.findViewById(R.id.tabsIcon);
  24. iv.setBackgroundResource(icon);
  25. TextView tv = (TextView) view.findViewById(R.id.tabsText);
  26. tv.setText(text);
  27. }
  28. return view;
  29. }
Add Comment
Please, Sign In to add comment