开发者

Activity group problem in tab bar

开发者 https://www.devze.com 2023-01-28 20:27 出处:网络
I have used tabbar with activity group in my application. I have four tab like home, stock, 开发者_Go百科citn, article. In my application first display home page from the home page user click in webvi

I have used tabbar with activity group in my application. I have four tab like home, stock, 开发者_Go百科citn, article. In my application first display home page from the home page user click in webview it will go to homepage1 activity. From home page1 activity user click stock tab it will go to stock activity. From the stock activity user click home tab it will go to homepage1 activity. I want to display home activity can any body tell how to do?

My question is switching between tab using activity group it will display last activity. I want to display first activity?

ok i will attach my code

spec = tabHost.newTabSpec("FirstGroup").setIndicator("FirstGroup",   
                getWallpaper()).setContent( new Intent(this,FirstGroup.class));
        tabHost.addTab(spec);   

View view = getLocalActivityManager().startActivity("CitiesActivity", new Intent(this,CitiesActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET )).getDecorView();

          // Replace the view of this ActivityGroup   
      replaceView(view);   

   }   

public void replaceView(View v) {   
            // Adds the old one to history   
    history.add(v);   
            // Changes this Groups View to the new View.   
    setContentView(v);

run this example http://united-coders.com/nico-heid/use-android-activitygroup-within-tabhost-to-show-different-activity

switching between activity and tab

I have posted in pastebin, my link is http://pastebin.com/1zG0HJgv


Hi Did u tried the tabchanged event as shown below

tabHost.addTab(tabHost.newTabSpec("tab1").setContent(
                R.id.content_movies).setIndicator("",
                getResources().getDrawable(R.drawable.icon)));
        tabHost.addTab(tabHost.newTabSpec("tab2").setContent(
                new Intent(this, Sample.class)).setIndicator("",
                getResources().getDrawable(R.drawable.menu_icon)));
    tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {

       @Override
       public void onTabChanged(String arg0) {


         if(arg0.equals("tab1"))
        {

       /*write the code here to show the view 
     Currentclass, the class where you have used ontabchanged function and 
     Newclass is the class where you want to navigate*/
           Intent obj_intent = new Intent(CureentClass.this,Newclass.class);
    startActivity(obj_intent);

        }

        else if (arg0.equals("tab2")) {

                 // write the code here to show the view 
       }
       //similarly for other tabs
      });
0

精彩评论

暂无评论...
验证码 换一张
取 消