I have tab bar with ViewPager and some List, that i can click and get my ViewPager behind fragmant. I have some issues with changing my android.support.v4.view.ViewPager with fragment by using replace. here is my layout in wich i contain them:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/orders_fragment"
android:name="fragments.OrderFragment1"
tools:layout="@layout/fragment_2" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primaryColor"/>
</RelativeLayout>
I'm trying to do it this way:
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction=manager.beginTransaction();
Fragment f1 = manager.findFragmentById(R.id.pager);
transaction.remove(f1);
transaction.commit();
}
});
Were i am wrong? can i do this in my way? or there is some special way to do this kind of things? Im new in this so if some1 have an example or something it wood be grate.