0

I need little bit help related to android tabhost. I have 3 tabs and 3 activities. MainTab activity is "extends from TabActivity" and other 2 activities are "extends from Activity".
In MainTab activity there are two buttons Radio and CheckBox, when user click radio button then i want to display radio button view in tab2. when user click check box i want to display checkbox view. Can some gives me an idea how I can achieve this?? Below is my code.

    public class MainTabHost extends TabActivity  implements OnTabChangeListener{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.homeui);

    TabHost tabHost = getTabHost(); 
    tabHost.setOnTabChangedListener(this);

    TabHost.TabSpec spec;  
    Intent intent; 

    intent = new Intent().setClass(this, Main.class);        
    spec = tabHost.newTabSpec("Main Tab").
    setIndicator("Main Tab")
                  .setContent(intent);
    spec.setIndicator("", this.getResources().getDrawable(R.drawable.maintabicon) );
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, TabA.class);
    spec = tabHost.newTabSpec("Tab A").
    setIndicator("Tab A")
                  .setContent(intent);
    spec.setIndicator("", this.getResources().getDrawable(R.drawable.tabaicon) );
    tabHost.addTab(spec);


    tabHost.setCurrentTab(0);       

}

@Override
public void onTabChanged(String tabId) {

}

}

1

1 Answer 1

1

You can use SharedPreference for this. So that when you choose radio button you can change your shared value to radio and when you use Check box change value to check box and use the view in your second tab according to the shared value.

1
  • Thanks for your reply. I want to start downloading process in in other tab from main tab. How I can do this? e.g in Tab A activity I have a methode like public void download(), I want to invoke this method from main tab activity. how i can do this?
    – Mudassar
    Jun 13, 2011 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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