Question

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.

No correct solution

OTHER TIPS

use this method too...

@Override public void onResume(){
    System.out.println("hello");
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top