Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. Android Application in TAB HOST TabActivity can't Start

Android Application in TAB HOST TabActivity can't Start

Scheduled Pinned Locked Moved Android
androidcom
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 10297947
    wrote on last edited by
    #1

    package com.tabs; import android.app.TabActivity; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.widget.TabHost; import android.widget.TabHost.TabSpec; @SuppressWarnings({ "unused", "deprecation" }) public class MainActivity extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); Resources res = getResources(); TabHost th = getTabHost(); Intent tb1 = new Intent().setClass(this, New_User.class); TabSpec tbs1 = th.newTabSpec("New_user").setIndicator("NEW USER", null) .setContent(tb1); Intent tb2 = new Intent().setClass(this, Login_user.class); TabSpec tbs2 = th.newTabSpec("login").setIndicator("LOGIN", null) .setContent(tb2); th.addTab(tbs1); th.addTab(tbs2); th.setCurrentTab(0); } }

    D D 2 Replies Last reply
    0
    • U User 10297947

      package com.tabs; import android.app.TabActivity; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.widget.TabHost; import android.widget.TabHost.TabSpec; @SuppressWarnings({ "unused", "deprecation" }) public class MainActivity extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); Resources res = getResources(); TabHost th = getTabHost(); Intent tb1 = new Intent().setClass(this, New_User.class); TabSpec tbs1 = th.newTabSpec("New_user").setIndicator("NEW USER", null) .setContent(tb1); Intent tb2 = new Intent().setClass(this, Login_user.class); TabSpec tbs2 = th.newTabSpec("login").setIndicator("LOGIN", null) .setContent(tb2); th.addTab(tbs1); th.addTab(tbs2); th.setCurrentTab(0); } }

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      So what exactly is your question? Have you single-stepped through the code using the debugger? Have you considered checking return values from function calls, or maybe surrounding the code with a try/catch block? :doh:

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

      1 Reply Last reply
      0
      • U User 10297947

        package com.tabs; import android.app.TabActivity; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.widget.TabHost; import android.widget.TabHost.TabSpec; @SuppressWarnings({ "unused", "deprecation" }) public class MainActivity extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); Resources res = getResources(); TabHost th = getTabHost(); Intent tb1 = new Intent().setClass(this, New_User.class); TabSpec tbs1 = th.newTabSpec("New_user").setIndicator("NEW USER", null) .setContent(tb1); Intent tb2 = new Intent().setClass(this, Login_user.class); TabSpec tbs2 = th.newTabSpec("login").setIndicator("LOGIN", null) .setContent(tb2); th.addTab(tbs1); th.addTab(tbs2); th.setCurrentTab(0); } }

        D Offline
        D Offline
        Dadecki
        wrote on last edited by
        #3

        Hello, I had similar problem. Please see my example: 1) Xml file (note android.support.v4 is used):

        1. Java file for Activity:

        MainActivity extends FragmentActivity
        implements YourFirstFragment.OnFragmentInteractionListener, YourSecondFragment.OnFragmentInteractionListener

        {
        private FragmentTabHost _yourTabHost;

        protected void onCreate(Bundle savedInstanceState)
        {
        _yourTabHost =(FragmentTabHost)findViewById(android.R.id.tabhost);
        _yourTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

        _yourTabHost.addTab(_mTabHost.newTabSpec("first_fragment").setIndicator("NameOnTab"), YourFirstFragment.class, null);
        _yourTabHost.addTab(_mTabHost.newTabSpec("second_fragment").setIndicator("NameOnTab"), YourSecondFragment.class, null);
        }
        }

        Hope this will help somehow.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups