user1662302
user1662302

Reputation:

Refreshing Android Tabs without Intent

Please how can I refresh the content of Tab 2 (tag 2,Live blog) without adding intent.

TabHost th = (TabHost)findViewById(R.id.tabhost1); th.setup();

     TabHost.TabSpec spec = th.newTabSpec("tag1")
     .setIndicator("Testimonies", getResources()
      .getDrawable(R.drawable.icon_testimonies_tab))
        .setContent(R.id.tab1);
           th.addTab(spec);


     spec = th.newTabSpec("tag2")
     .setIndicator("Live Blog", getResources()
     .getDrawable(R.drawable.icon_liveblog_tab))
      .setContent(R.id.tab2);
        th.addTab(spec);


        spec = th.newTabSpec("tag3")
        .setIndicator("Streaming Settings", getResources()
        .getDrawable(R.drawable.icon_streamingsetting_tab))
        .setContent(R.id.tab3);
          th.addTab(spec);

          th.setCurrentTab(1);

          th.getCurrentView().setVisibility(View.VISIBLE);

Upvotes: 2

Views: 296

Answers (1)

xarlymg89
xarlymg89

Reputation: 2617

We "see" each other again, @meduteniopeyemi ! I worked hard trying to solve the issue you are talking about. And the aproach that I used to do it was:

tabHost.setOnTabChangedListener(new OnTabChangeListener() {

                    public void onTabChanged(String tabId) {
                            //YOUR CODE checking if "tabId" is the tab you want to REFRESH
                    }
            });

It worked so far for me. It just allows you to do any refreshing without problems.

Upvotes: 1

Related Questions