Replace fragment in tab


November 2018


336 time


I am trying to implement an Action Bar with Tabs navigation set using ActionBarSherlock. I currently have three tabs which I can switch between ok. On one of my tabs I am implementing a ListView. When one of the items in the list is selected I want to replace the list with another fragment which will be a detail view of the selection.

When I call the FragmentTransaction.replace method with the new detail fragment I can see the new fragment appear but it overlaps the ListView, meaning I can see both fragments. Is this kind of navigation possible using the ActionBar tabs navigation, or am I on completely the wrong lines. I feel I am missing something really fundamental here.

I have a SherlockFragmentActivity which is implementing a TabListener to handle moving between tabs. The fragment hosting the ListView inherits from SherlockListFragment and I have attached a OnItemClickListener to respond to the tap and to replace the fragment. I am using this code

numbersList.setOnItemClickListener(new ListView.OnItemClickListener() {
    public void onItemClick(AdapterView<?> a, View v, int i, long l) {
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(, new NumberSelectedNavigationMenuFragment());    

The fragment which is replacing the ListView is currently just a basic LinearLayout with a TextView.

<LinearLayout xmlns:android=""


Any help appreciated with this as I am well and truly stuck ...

0 answers