0

Good afternoon,

I am making an application in android, and I'm doing the layout for tab. But a problem arose when changing tab because it only gets updated when I open the first time after that is not updated.

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_favoritos);

        System.out.println("hello");

    }

this tab, it will only show this System.out.println. just shows once again the "hello".

What can I do?

My main:

public class MainActivity extends TabActivity {

    private HorizontalScrollView hsvTabs;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        hsvTabs = (HorizontalScrollView) findViewById(R.id.hsvTabs);
        TabHost tabHost = getTabHost();


        //home tab
        TabSpec homespec = tabHost.newTabSpec(getString(R.string.home));
        homespec.setIndicator(getString(R.string.home));
        Intent homeIntent = new Intent(this, MenuActivity.class);
        homespec.setContent(homeIntent);

        // municipios tab
        TabSpec mapaspec = tabHost.newTabSpec(getString(R.string.mapa));
        mapaspec.setIndicator(getString(R.string.mapa));
        Intent mapaIntent = new Intent(this, Map.class);
        mapaspec.setContent(mapaIntent);

        // meses tab
        TabSpec favoritospec = tabHost.newTabSpec(getString(R.string.favorito));
        favoritospec.setIndicator(getString(R.string.favorito));
        Intent favoritoIntent = new Intent(this, FavoritoActivity.class);
        favoritospec.setContent(favoritoIntent);

        // info tab
        TabSpec pontospec = tabHost.newTabSpec(getString(R.string.lb_pontos));
        pontospec.setIndicator(getString(R.string.lb_pontos));
        Intent pontoIntent = new Intent(this, PontoActivity.class);
        pontospec.setContent(pontoIntent);

        // Adding all TabSpec to TabHost
        tabHost.addTab(homespec);
        tabHost.addTab(mapaspec);
        tabHost.addTab(pontospec);
        tabHost.addTab(favoritospec);

My problem is that when I select one tab, then move to another, and when I returned the same is no longer updated.

2
  • you question is not clear at all, post some code and elaborate your problem Dec 29, 2013 at 14:39
  • already added more code Dec 29, 2013 at 17:06

1 Answer 1

0

use this method too...

@Override public void onResume(){
    System.out.println("hello");
}

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.