使用标签小部件制作基于标签主机的应用程序。当我从嵌套活动返回到标签活动时,标签小部件消失。有没有办法恢复标签小部件?
以下是代码:
HomeActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
tabHost = getTabHost();
tabHost.setOnTabChangedListener(this);
Intent intent;
intent = new Intent().setClass(this, ListingActivity.class);
//spec = tabHost.newTabSpec("Listing").setIndicator("Listing").setContent(intent);
spec = tabHost.newTabSpec("Sales").setIndicator("", getResources().getDrawable(R.drawable.listing_selector)).setContent(intent);
tabHost.addTab(spec);
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
intent = new Intent().setClass(this, DonateActivity.class);
//spec = tabHost.newTabSpec("Donate").setIndicator("Donate").setContent(intent);
spec = tabHost.newTabSpec("Sales").setIndicator("", getResources()
.getDrawable(R.drawable.donate_selector)).setContent(intent);
tabHost.addTab(spec);
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
tabHost.getTabWidget().setCurrentTab(0);
tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#FFFFFF "));
}
当我使用后退按钮时,会显示相应的活动,但不显示选项卡小部件。
以下是backbutton的代码段:
ProfileActivity
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Profile.this, HomeActivity.class));
}
});
}