Tab widget disappears

41 Views Asked by At

Am making an application based on tab host with tab widget. when I get back from nested activity to tab activity, tab widget disappears. Is there any way to bring back the tab widget?

Below is the code:

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 "));
}

When I use backbutton the corresponding activity appears but tab widget doesn't appear.

Below is the snippet for backbutton:

ProfileActivity

back.setOnClickListener(new View.OnClickListener() {

          @Override

   public void onClick(View v) {

          startActivity(new Intent(Profile.this, HomeActivity.class));
}
        });

   }
0

There are 0 best solutions below