0

I've got a TabHost with some tabs. I haven't got problem managing them but what I need now is this: I have an "activity" called in the TabContent and i need that a button from that Activity/Layout changes the content of the Tab. How can I do that? I can't find a solution.

Orodreth
  • 3
  • 1

1 Answers1

0

Use OnClickListener for your botton, use findViewById and change content. What's the problem?

UPDATE

At MainActivity:

    Resources res = getResources();
    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;

    intent = new Intent().setClass(this, CatalogActivity.class);
    String txtCatalog = (String) getText(R.string.catalog);
    spec = tabHost.newTabSpec("catalog").setIndicator(txtCatalog,
            res.getDrawable(R.drawable.ic_tab_catalog)).setContent(intent);
    tabHost.addTab(spec);

At ChildActivity (equals A):

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {     
    if(!items.get(position).isGroup()){         
        Category item = (Category)items.get(position);          
        Intent newintent = new Intent(getBaseContext(), CategoryActivity.class);
        newintent.putExtra("pid", item.id);
        startActivity(newintent);
    }       
    super.onListItemClick(l, v, position, id);
}
Danil Onyanov
  • 210
  • 1
  • 4
  • 16
  • Maby I explain badly myself. postimg.org/image/xzsdixh77 (I cant upload images) I need to change from content A to content C clicking the button but it needs to happen in the TabContent – Orodreth Mar 27 '14 at 10:31
  • I updated from my old project with same feature. Now I'll try to find a tutorial I used then. – Danil Onyanov Mar 27 '14 at 12:22
  • here it is: http://www.javacodegeeks.com/2013/04/android-child-group-activity.html And relative question: http://stackoverflow.com/questions/20988505/open-child-activity-in-tab-host-android – Danil Onyanov Mar 27 '14 at 12:24