Search code examples
androidfragment-tab-host

How top set tab icon and label in FragmentTabHost


I am using FragmentTabHost to implement bottom tabs with icon and label but following sentence shows only label

mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple",getResources().getDrawable(R.drawable.ic_launcher)),
            Fragment1.class, b);

I also see somewhere following works properly

setIndicator(View);

but I don't know syntax to set custom view in setIndicator

plz help Thanks...


Solution

  • I make custom view and set it as setIndicator(View v);

    View chatView=LayoutInflater.from(this).inflate(R.layout.chat_icon,null);
        mTabHost.addTab(mTabHost.newTabSpec("simple").setIndicator(chatView),
                Fragment1.class, b);