Ejemplo n.º 1
0
  private static void AddTab(
      Activity_Tab activity,
      TabHost tabHost,
      TabHost.TabSpec tabSpec,
      TabInfo tabInfo,
      String label,
      int drawable) {
    tabSpec.setContent(activity.new TabFactory(activity));

    View tabIndicator =
        LayoutInflater.from(activity)
            .inflate(R.layout.tab_indicator, tabHost.getTabWidget(), false);
    TextView txtTitle = (TextView) tabIndicator.findViewById(R.id.title);
    ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);

    txtTitle.setText(label);
    txtTitle.setTextSize(
        Float.parseFloat(activity.getResources().getString(R.string.size_pointer)));
    txtTitle.setTypeface(StaticUtils.getTypeface(activity, Font.THSarabanNew));
    icon.setImageResource(drawable);

    tabSpec.setIndicator(tabIndicator);

    tabHost.addTab(tabSpec);
  }
Ejemplo n.º 2
0
  private void initialiseTabHost(Bundle args) {
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();

    TabInfo tabInfo = null;
    if (AppMain.isphone) {

      Activity_Tab.AddTab(
          this,
          this.mTabHost,
          this.mTabHost.newTabSpec("Tab1").setIndicator("Tab 1"),
          (tabInfo = new TabInfo("Tab1", Fragment_Ebook_Mode.class, args)),
          getResources().getString(R.string.book_tab_title),
          R.drawable.tab_ebooks);
      Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);

      // Activity_Tab.AddTab(this, this.mTabHost,
      // this.mTabHost.newTabSpec("Tab2").setIndicator("Tab 2"),
      // (tabInfo = new TabInfo("Tab2", Fragment_Publisher.class, args)),
      // "publisher", R.drawable.tab_publishers);
      // Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);
      //
      // Activity_Tab.AddTab(this, this.mTabHost,
      // this.mTabHost.newTabSpec("Tab3").setIndicator("Tab 3"),
      // (tabInfo = new TabInfo("Tab3", Fragment_Category.class, args)),
      // "category", R.drawable.tab_category);
      // Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);
      //
      // Activity_Tab.AddTab(this, this.mTabHost,
      // this.mTabHost.newTabSpec("Tab4").setIndicator("Tab 4"),
      // (tabInfo = new TabInfo("Tab4", Fragment_Top.class, args)), "top",
      // R.drawable.tab_top);
      // Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);

      Activity_Tab.AddTab(
          this,
          this.mTabHost,
          this.mTabHost.newTabSpec("Tab5").setIndicator("Tab 5"),
          (tabInfo = new TabInfo("Tab5", Fragment_Shelf.class, args)),
          getResources().getString(R.string.shelf_tab_title),
          R.drawable.tab_bookshelf);
      Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);

      // STOU
      Activity_Tab.AddTab(
          this,
          this.mTabHost,
          this.mTabHost.newTabSpec("Tab6").setIndicator("Tab 6"),
          (tabInfo = new TabInfo("Tab6", Fragment_Contact.class, args)),
          getResources().getString(R.string.contact_tab_title),
          R.drawable.tab_contact);
      Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);

      mTabHost.setOnTabChangedListener(this);

      if (Shared_Object.isOfflineMode) {
        mTabHost.setCurrentTabByTag("Tab5");
      } else {
        this.onTabChanged("Tab1");
      }

    } else {

      Activity_Tab.AddTab(
          this,
          this.mTabHost,
          this.mTabHost.newTabSpec("Tab1").setIndicator("Tab 1"),
          (tabInfo = new TabInfo("Tab1", Fragment_Ebook_Mode.class, args)),
          getResources().getString(R.string.book_tab_title),
          R.drawable.tab_ebooks);
      Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);

      // Activity_Tab.AddTab(this, this.mTabHost,
      // this.mTabHost.newTabSpec("Tab2").setIndicator("Tab 2"),
      // (tabInfo = new TabInfo("Tab2", Fragment_Publisher.class, args)),
      // "publisher", R.drawable.tab_publishers);
      // Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);
      //
      // Activity_Tab.AddTab(this, this.mTabHost,
      // this.mTabHost.newTabSpec("Tab3").setIndicator("Tab 3"),
      // (tabInfo = new TabInfo("Tab3", Fragment_Top.class, args)), "top",
      // R.drawable.tab_top);
      // Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);

      Activity_Tab.AddTab(
          this,
          this.mTabHost,
          this.mTabHost.newTabSpec("Tab4").setIndicator("Tab 4"),
          (tabInfo = new TabInfo("Tab4", Fragment_Shelf.class, args)),
          getResources().getString(R.string.shelf_tab_title),
          R.drawable.tab_bookshelf);
      Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);

      // STOU
      Activity_Tab.AddTab(
          this,
          this.mTabHost,
          this.mTabHost.newTabSpec("Tab5").setIndicator("Tab 5"),
          (tabInfo = new TabInfo("Tab5", Fragment_Contact.class, args)),
          getResources().getString(R.string.contact_tab_title),
          R.drawable.tab_contact);
      Activity_Tab.mapTabInfo.put(tabInfo.tag, tabInfo);

      mTabHost.setOnTabChangedListener(this);

      if (Shared_Object.isOfflineMode) {

        mTabHost.setCurrentTabByTag("Tab4");
      } else {
        this.onTabChanged("Tab1");
      }
    }
  }