Note that there are some explanatory texts on larger screens.

plurals
  1. POReplacing a Fragment: Previous view remains Active in the background?
    primarykey
    data
    text
    <p>I am working on an application where I have to change the view of one tab when tab is changed. I am doing it following way using <code>OnTabChangedListener</code>. I am able to replace view. But when I change my tab to some other tab, previous view remain tapable in the background? Why is it so? In front, new view is populated but If I tap anywhere on the screen where previous view's controls were, the functionality is executed. I am not getting where may the problem lie. Please help me out. Thanks!</p> <pre><code>public class FragmentTabs extends FragmentActivity implements OnTabChangeListener { private FragmentTabHost mTabHost; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.fragment_tabs); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); mTabHost.setOnTabChangedListener(this); if (Database.getSharedObject(getApplicationContext()).getAppSettings().getListView() == 1) { mTabHost.addTab(mTabHost.newTabSpec("home").setIndicator("", getResources().getDrawable(R.drawable.home_tab)), HomeFragment.class, null); } else { mTabHost.addTab(mTabHost.newTabSpec("home").setIndicator("", getResources().getDrawable(R.drawable.home_tab)), CalendarViewFragment.class, null); } mTabHost.addTab(mTabHost.newTabSpec("groups").setIndicator("", getResources().getDrawable(R.drawable.groups_tab)), GroupFragment.class, null); mTabHost.addTab(mTabHost.newTabSpec("templates").setIndicator("", getResources().getDrawable(R.drawable.templates_tab)), TemplateFragment.class, null); mTabHost.addTab(mTabHost.newTabSpec("settings").setIndicator("", getResource mTabHost.getTabWidget().getChildAt(0).getLayoutParams().height = height; mTabHost.getTabWidget().getChildAt(1).getLayoutParams().height = height; mTabHost.getTabWidget().getChildAt(2).getLayoutParams().height = height; mTabHost.getTabWidget().getChildAt(3).getLayoutParams().height = height; // Database.getSharedObject(getApplicationContext()); mTabHost.setCurrentTab(0); } @Override protected void onResume() { super.onResume(); } @Override public void onTabChanged(String arg0) { mTabHost.getCurrentTabView().invalidate(); if (mTabHost.getCurrentTab() == 0) { if (Database.getSharedObject(getApplicationContext()).getAppSettings().getListView() == 1) { HomeFragment homeFragment = new HomeFragment(); mTabHost.getCurrentTabView().invalidate(); getSupportFragmentManager().beginTransaction().replace(R.id.realtabcontent, homeFragment).addToBackStack(null).commit(); } else { CalendarViewFragment calendarViewFragment = new CalendarViewFragment(); mTabHost.getCurrentTabView().invalidate(); getSupportFragmentManager().beginTransaction().replace(R.id.realtabcontent, calendarViewFragment).addToBackStack(null).commit(); } } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload