Code example for TabHost

Methods: getContextaddTabnewTabSpec

0
                res.getDrawable(R.drawable.icon_favorite),
                new Intent().setClass(this, SecondTabActivity.class));
    } 
 
    private void setupTab(final View view, final String tag, String text, Drawable icon, Intent intent) {
        View tabView = createTabView(mTabHost.getContext(), text, icon);
        TabSpec tabSpec = mTabHost.newTabSpec(tag);
 
        tabSpec.setIndicator(tabView);
        tabSpec.setContent(intent);
        mTabHost.addTab(tabSpec);
    } 
 
    private static View createTabView(final Context context, final String text, final Drawable icon) {
        View view = LayoutInflater.from(context).inflate(R.layout.tab_bg, null);
        TextView textView = (TextView) view.findViewById(R.id.text);
        textView.setText(text);
 
        ImageView imageView = (ImageView) view.findViewById(R.id.icon);
        imageView.setImageDrawable(icon);
Stop searching for code, let great code find you!  Add Codota to your java IDE