Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create Custom Tab In Android Application

Tags:

android

thanks advance..

when i create custom tab in android application so no one tab display in main screen

how to solve this problem please any one tell me?

like image 998
Chirag Patel Avatar asked Feb 02 '26 11:02

Chirag Patel


1 Answers

you mean that you want to create custom tab for your application.ok now you have two class that is homemyclass.java and myclass.java. At first you declare flowing two line in homemyclass.java

private Intent mytab;
private static final String TAB_MYCLASS = "myclass";

then you write flowing line into onCreate() function of homemyclass.java

mytab = new Intent(this, myclass.class);
addTab(TAB_MYCLASS, getString(R.string."label for tab"), R.drawable."icon for tab display when 
tab is  selected",   R.drawable."icon for tab display when tab is not selected", mytab);

just add addTab() into homemyclass.java

private void addTab(String tag, String label, int icon, int ficon, Intent content) {
    TabHost tabHost = getTabHost();
    TabSpec tabspecDialer = tabHost.newTabSpec(tag).setContent(content);

    //boolean fails = true;

        tabspecDialer.setIndicator(label, getResources().getDrawable(icon));


    tabHost.addTab(tabspecDialer);
}

you also need to modify androidManifest.xml by homemyclass.java and myclass.java

like image 166
rabby Avatar answered Feb 05 '26 08:02

rabby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!