Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am creating a tab view and linking those tabs to 4 different classes but my project is not running due to the following errors:

java.lang.RuntimeException: Unable to start activity ComponentInfo{infocular.SiteAuditPro/infocular.SiteAuditPro.SiteAuditPro}: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    at android.app.ActivityThread.access$600(ActivityThread.java:141)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5041)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
    at android.app.TabActivity.onContentChanged(TabActivity.java:131)
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:273)
    at android.app.Activity.setContentView(Activity.java:1881)
    at infocular.SiteAuditPro.SiteAuditPro.onCreate(SiteAuditPro.java:27)
    at android.app.Activity.performCreate(Activity.java:5104)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
share|improve this question
please help me with the problem – user2549788 53 mins ago
clearly written on logcat – Mohit 51 mins ago
what's your java and xml – Mohit 48 mins ago

1 Answer

This is my way to add view group to tabs

private TabHost     tabs = (TabHost) findViewById(R.id.tabhost);
        tabs.setup();

        TabSpec HP_tab = tabs.newTabSpec("tab_six_btn_tab");
        HP_tab.setContent(R.id.scroll);
        HP_tab.setIndicator("HP World");
        tabs.addTab(HP_tab);

        TabSpec notebook_tab = tabs.newTabSpec("tab_one_btn_tab");

        notebook_tab.setContent(R.id.Notebook_Tab);
        notebook_tab.setIndicator("Notebook");
        tabs.addTab(notebook_tab);

        TabSpec desktop_tab = tabs.newTabSpec("tab_two_btn_tab");
        desktop_tab.setContent(R.id.Desktop_Tab);
        desktop_tab.setIndicator("Desktop");
        tabs.addTab(desktop_tab);

        TabSpec pos_tab = tabs.newTabSpec("tab_three_btn_tab");
        pos_tab.setContent(R.id.POS_tab);
        pos_tab.setIndicator("POS");
        tabs.addTab(pos_tab);

        TabSpec Promotion_tab = tabs.newTabSpec("tab_four_btn_tab");
        Promotion_tab.setContent(R.id.Promotion_Tab);
        Promotion_tab.setIndicator("Promotion");
        tabs.addTab(Promotion_tab);

        TabSpec Hard_tab = tabs.newTabSpec("tab_five_btn_tab");
        Hard_tab.setContent(R.id.HardBranding_Tab);
        Hard_tab.setIndicator("Hard Branding");
        tabs.addTab(Hard_tab);

        tabs.getTabWidget().getChildAt(0).getLayoutParams().height = 30;
        tabs.getTabWidget().getChildAt(1).getLayoutParams().height = 30;
        tabs.getTabWidget().getChildAt(2).getLayoutParams().height = 30;
        tabs.getTabWidget().getChildAt(3).getLayoutParams().height = 30;
        tabs.getTabWidget().getChildAt(4).getLayoutParams().height = 30;
        tabs.getTabWidget().getChildAt(5).getLayoutParams().height = 30;
        Display display = getWindowManager().getDefaultDisplay();
        display.getWidth();
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.