How to create a custom tab in an Android application

thanks in advance..

when I create a custom tab in an Android application, so no tab appears on the main screen

How to solve this problem, please tell me someone?

+3
source share
1 answer

you mean that you want to create a custom tab for your application. Now you have two classes - homemyclass.java and myclass.java. First you declare the current two lines in homemyclass.java

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

then you write the current line to the 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 () to 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 change androidManifest.xml to homemyclass.java and myclass.java

+3
source

All Articles