Android ViewSwitcher with slices

I have a snippet with a list of items. When an element is clicked, I need to show the details of this element in another fragment. Basically, I am looking for something similar to the challenge of a new activity from another activity. Since I use fragments, I always use the code below to display another fragment from one fragment:

FragmentTransaction transaction = getFragmentManager().beginTransaction();
Fragment fragment = new LoginFragment();
transaction.replace(R.id.login_Or_FeatureContainer, fragment);
transaction.commit();

In the above example, I am replacing the layout for the new content that will be presented.

Is there any other option besides replacement?

As I'm not sure how to switch from one fragment to another for my scenario described above, I am trying to use ViewSwitcher as shown below:

<ViewSwitcher
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/viewSwitcher" >

    <fragment
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:name="com.fragments.ItemFragment"
        android:id="@+id/fragment"
        tools:layout="@layout/fragment_item" />

    <fragment
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:name="com.fragments.Fragment_Offer_Voucher_Detail"
        android:id="@+id/fragment2"
        tools:layout="@layout/fragment_offer_detail" />
</ViewSwitcher>

, view switcher. - , .

. ViewSwitcher?

.

+4

All Articles