Android Open Fragment over ViewPager

I am new to Android programming, and I am trying to create an application that uses tabs in the viewpager from one main fragmentation. The viewpager and the tabs work fine, but I want to have an options menu that, when an item is selected, opens a whole new fragment, but I seem to be unable to remove the view pager. I would just like to add a new fragment on top of the viewpager on the main screen, but trying to do this with fragmentation doesn't work

Any ideas?

thank you for your time

+5
source share
2 answers

, Fragment FrameLayout, FrameLayout, . , FrameLayout, Fragment, ViewPager.

, ViewPager FrameLayout RelativeLayout, , FrameLayout ViewPager XML. FragmeLayout ViewPager. Fragment FrameLayout, .

+2

, :

1) (: ViewPagerFragment1), viewpager, FrameLayout "", :

<FrameLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/container"
xmlns:android="http://schemas.android.com/apk/res/android">

       <LinearLayout.... and so on
</FrameLayout>

2) ViewPagerFragment1 / FrameLayout , . :.

 @Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.selection:
            // Create new fragment and transaction
            NewFragment newFragment = new NewFragment();
            FragmentTransaction transaction = getFragmentManager().beginTransaction();

            transaction.replace(R.id.container, newFragment, "NewFragment");
            transaction.addToBackStack(null);

            transaction.commit();
            break;
         default:
            break;
    }
}
+2

All Articles