I am using ActionBarSherlock's action bar tabs in my application with each tab populated by a single fragment inside a SherlockActivity Tabs.
One of my Tabs contains a fragment, FragmentHome, with a list of news articles. When an article is selected, FragmentHome is replaced by another fragment, FragmentNews. FragmentNews just contains a webview to load the selected article. The article is loaded fine. I override the onBackPressed in my activity so that FragmentHome is reattached and FragmentNews is removed. While there are no errors, the webview inside FragmentHome is never removed from the view and overlaps with other fragments. (See screenshots). Tested it for API Level 9 and 17. 1) FragmentHome - Displayed normally - http://s16.postimg.org/bzq5xv7c5/SC20130427_184700.png 2) FragmentNews - Displayed normally - http://s15.postimg.org/l88zyy23f/SC20130427_184705.png 3) Webview from FragmentNews overlapping FragmentHome after fragment transactioon -http://s22.postimg.org/6mg8aaze9/SC20130427_184710.png Its weird because the same code works for another SherlockFragment with ListView in it but is messed up when using a WebView. Here is the code to replace FragmentHome with FragmentNews initially: ------------------------------ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { listNews.setItemChecked(position, true); Bundle bundle = new Bundle(); bundle.putStringArray("NEWS", new String[] { mNews.newsFeed.get(position).getTitle(), mNews.newsFeed.get(position).getLink() .toExternalForm() }); FragmentTransaction ft = getSherlockActivity() .getSupportFragmentManager().beginTransaction(); Fragment frag = SherlockFragment.instantiate(getSherlockActivity(), FragmentNews.class.getName(), bundle); ft.detach(getSherlockActivity().getSupportFragmentManager() .findFragmentById(getId())); ft.add(android.R.id.content, frag, Tabs.FRAG_NEWS); ft.commit(); } Code in onBackPressed in the Activity hosting the fragments: ------------------------------------------------------------------------------------------ @Override public void onBackPressed() { Fragment frag = getSupportFragmentManager().findFragmentByTag( FRAG_DETAILS); if (frag != null && frag.isVisible()) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(frag); Fragment mFragment = getSupportFragmentManager().findFragmentByTag( TAB_PORTFOLIO); if (mFragment == null) { mFragment = SherlockFragment.instantiate(this, FragmentPortfolioList.class.getName(), null); ft.add(android.R.id.content, mFragment, TAB_PORTFOLIO); } else { ft.attach(mFragment); } ft.commit(); } else { // Code to replace FragmentNews which contains the webview. frag = getSupportFragmentManager().findFragmentByTag(FRAG_NEWS); if (frag != null && frag.isVisible()) { Log.e("onBackPressed", "for " + frag.getTag()); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.remove(frag); Fragment mFragment = getSupportFragmentManager() .findFragmentByTag(TAB_HOME); if (mFragment == null) { mFragment = SherlockFragment.instantiate(this, FragmentHome.class.getName(), null); ft.add(android.R.id.content, mFragment, TAB_HOME); } else { ft.attach(mFragment); } ft.commit(); } else { Log.e("onBackPressed", "inside else"); super.onBackPressed(); } } } I have seen posts talking about FlashPlayer causing issues because of SurfaceView cutting a hole but I am just displaying simple webpages without any videos. Help highly appreciated. -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

