下午好,
我正在android中创建一个应用程序,我正在做tab的布局。但是在更改选项卡时会出现问题,因为只有在我没有更新后第一次打开时它才会更新。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_favoritos);
System.out.println("hello");
}
此选项卡,它只显示此System.out.println。再次展示“你好”。
我该怎么办?
我的主要人物:
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);
我的问题是,当我选择一个标签,然后移动到另一个标签,当我返回时,不再更新。
答案 0 :(得分:0)
也使用这种方法......
@Override public void onResume(){
System.out.println("hello");
}