繁体   English   中英

Android:单击按钮后更改TabWidget意图?

[英]Android: changing TabWidget intent after button click?

在我的应用程序中,我首先向用户显示免责声明页面作为“主页”选项卡。 该页面包含一个文本框和一个提交按钮,该按钮将用户名存储到SharedPreferences中。 我想更改“主页”选项卡的意图,以显示“谢谢”页面而不是“免责声明”页面。 我目前在TabActivity类的onCreate()方法下具有以下功能。 问题在于,当用户提交用户名时,它不会刷新新的意图。

String pulledUsername = getSharedPreferences("com.blah.application", MODE_PRIVATE).getString("username",null);

     if (pulledUsername != null){
            intent = new Intent().setClass(this, HomeActivity.class);
            spec = tabHost.newTabSpec("home").setIndicator("Home",
                    res.getDrawable(R.drawable.ic_tab_home))
                .setContent(intent);
            tabHost.addTab(spec);
            }
            else {
            intent = new Intent().setClass(this, DisclaimerActivity.class);
            spec = tabHost.newTabSpec("home").setIndicator("Home",
                    res.getDrawable(R.drawable.ic_tab_home))
                .setContent(intent);
            tabHost.addTab(spec);
            }

我想在用户单击“提交”后更改“主页”选项卡的意图,或者让TabWidget主动检查以查看pullUsername是否存储在电话中,而不仅仅是onCreate()。

通过使用解决

startActivity(new Intent(DisclaimerActivity.this, TabWidgetActivity.class)); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM