android-viewpager

Replacing Fragments correctly within ViewPager

我的未来我决定 提交于 2020-01-01 11:56:08
问题 I'am trying to replace a fragment within a view, but don't succeed yet. I have the following classes. First my PagerAdapter: package com.example.tab1; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; public class SectionsPagerAdapter extends FragmentPagerAdapter { static final int NUM_ITEMS = 3; private final FragmentManager mFragmentManager; private Fragment mFragmentAtPos0;

Replacing Fragments correctly within ViewPager

China☆狼群 提交于 2020-01-01 11:56:04
问题 I'am trying to replace a fragment within a view, but don't succeed yet. I have the following classes. First my PagerAdapter: package com.example.tab1; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; public class SectionsPagerAdapter extends FragmentPagerAdapter { static final int NUM_ITEMS = 3; private final FragmentManager mFragmentManager; private Fragment mFragmentAtPos0;

Custom font color for PagerTabStrip in ViewPager for my Android app

梦想的初衷 提交于 2020-01-01 10:57:10
问题 I need to change the font color for PagerTabStrip in ViewPager for my Android app. This is the xml layout for the same. Is there any way I can do this? <android.support.v4.view.ViewPager android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/head" android:id="@+id/myfivepanelpager"> <android.support.v4.view.PagerTabStrip android:id="@+id/pgstrip" android:layout_width="fill_parent" android:background="@color/strip" android:layout_height="@dimen

ViewPager retaing old Fragments on screen rotation

[亡魂溺海] 提交于 2020-01-01 10:15:37
问题 I am using ViewPager and FragmentStatePagerAdapter to show fragment. Initially there are 2 fragments added Fragment1 and Fragment2 and 3rd fragment Fragment3 is added at 2nd position after recieiving response from server. So after all pages are added this should be sequence of Fragments in ViewPager --> Fragment1, Fragment3, Fragment2. The Problem is after Fragment1 and Fragment3 are added and app is making server call before adding 3rd Fragment at 2nd position if I do screen rotation

How to go other Tabs by clicking on a Button from the current Tab in Android?

北战南征 提交于 2020-01-01 09:34:12
问题 I trying to write a code in Android, to switch from one tab to another tab by click on a button. I know to by clicking on tab we can switch from one tab to another but can it be possible to switch from one tab to another tab by clicking on one button. I tried the following tutorial. http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/ In this tutorial i have edited the MovieFragment.java file in following manner. MovieFragment.java package info.androidhive.tabsswipe;

Challenge: Custom Animation of ViewPager. Change height of chosen elements (View fold)

陌路散爱 提交于 2020-01-01 09:13:22
问题 I am currently working on custom animation between switching pages in ViewPager. When I slide to the left, View is moving to the left and from below of it new View is coming to the front. I would like to make the view, that moves to the left (that I dispose) to shrink like on the folowing images: On the second and third image I didn't picture new View coming to the front, but I think it wasn't necessary. Do you have any idea how can I modify the code? I would like to change height of

ViewPager's height in Coordinator layout is more than available

大憨熊 提交于 2020-01-01 08:55:46
问题 I have a CoordinatorLayout with a Toolbar and a TabLayout inside the AppBarLayout . Additionally, I have a ViewPager inside the CoordinatorLayout but outside the ViewPager . The problem is that the ViewPager's height is bigger than what is actually available, resulting in some views from my Fragment being cut. <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com

Android ViewPager manually call PageTransformer transformPage

二次信任 提交于 2020-01-01 08:46:12
问题 I have a ViewPager with the PageTransformer implementation that does some funky stuff to the next page of the ViewPager. My implementation looks like this: class ZoomOutPageTransformer implements ViewPager.PageTransformer { private static final float MIN_SCALE = 0.85f; private static final float MIN_ALPHA = 0.5f; @Override public void transformPage(View view, float position) { int pageWidth = view.getWidth(); if (position < -1) { // [-Infinity,-1) // This page is way off-screen to the left.

Android ViewPager manually call PageTransformer transformPage

江枫思渺然 提交于 2020-01-01 08:46:11
问题 I have a ViewPager with the PageTransformer implementation that does some funky stuff to the next page of the ViewPager. My implementation looks like this: class ZoomOutPageTransformer implements ViewPager.PageTransformer { private static final float MIN_SCALE = 0.85f; private static final float MIN_ALPHA = 0.5f; @Override public void transformPage(View view, float position) { int pageWidth = view.getWidth(); if (position < -1) { // [-Infinity,-1) // This page is way off-screen to the left.

Save State and Restore State in FragmentStatePagerAdapter

隐身守侯 提交于 2020-01-01 05:27:08
问题 I a using ViewPager with FragmentStatePageAdapter on my screen I have 5 pages which has lots of images and views. Currently I have mViewPager.setOffscreenPageLimit(1); so only current, previous and next will be in memory and other 2 will be destroyed. But for that destroyed fragments I want to make use of saveState() and restoreState() of the adapter to maintain its state so when I come back to that screen it will anyways go to onCreateView() of that fragment what will maintain state also.