android-viewpager

Android viewpager animation

别说谁变了你拦得住时间么 提交于 2019-12-21 16:48:12
问题 I would like to be informed when the animation ends after this function call: viewPager.setCurrentItem(2, true); Does anyone know how to accomplish this? 回答1: I have come across the same issue. the following is my conclusion: When the page is actually changed onPageSelected will be called. But it's called before the animation. When the animation stopped , onPageScrollStateChanged will be called with state SCROLL_STATE_IDLE. So you have to combine this two function calls to get your function

Android - Getting context of a fragment in a pager

我是研究僧i 提交于 2019-12-21 15:25:31
问题 I have a android application using a pager as navigation. For the tabs I have 3 layouts as content. On one of the fragments is a gallery and I want to add images to it. For that I have to set an ImageAdapter but I need to know how to access the context of a fragment. final LayoutInflater factory = getLayoutInflater(); final View view = factory.inflate(R.layout.pictures, null); Gallery g = (Gallery) view.findViewById(R.id.gallery1); g.setAdapter(new ImageAdapter(view.getContext())); I use this

getActivity returning null from fragment

风格不统一 提交于 2019-12-21 12:50:29
问题 For school I am making an android app. For this app I have a fragment, which shows a gridview with just strings, from a database. For this I need a fragment. When I call getActivity(), it returns null. The onAttach method, as suggested here doesn't get called before the app crashes. How should I solve this? weekFragmetn.xml: package nl.siebeh.schoolmate; import java.util.ArrayList; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.support.v4

PagerSlidingTabStrip: How refresh inner fragment Listview in current tab at run time and stop the loading data for next tab

被刻印的时光 ゝ 提交于 2019-12-21 12:24:19
问题 I got stuck into the problem with listview used with inner fragment insideNavigation-drawer-page-sliding-tab-strip viewpager tabs, that given in This git hub example. i am using the same example and All 4 tabs having a list view with different arraylist set to there adapters. I am using only one fragment and bases of tabs position I am loading different list data to inner fragment arrayAdapter. Also I have two buttons one is delete and another one is Add. What I want : If I press the add

ViewPager Fragments are not initiated in onCreate

瘦欲@ 提交于 2019-12-21 11:56:08
问题 I seem to be having an issue updating the fragments that I am using in my ViewPager, regardless of whether I try in onCreate(), onCreateView(), or onResume(). Here is how I'm setting up my ViewPager in my MainFragment: public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main_screen, container, false); mPager = (ViewPager)rootView.findViewById(R.id.pager); mPager.setOffscreenPageLimit(2); // So

ViewPager inside Fragment loses content when returning to it

懵懂的女人 提交于 2019-12-21 09:34:51
问题 I am implementing tabhost using FragmentActivity , under the first tab i load a welcome fragment that contains a Viewpager and CirclePageIndIcator , I need to load 4 views in side that WelcomeFragment this is my WelcomeFragment public class WelcomeFragment extends Fragment { PageAdapter mAdapter; ViewPager mPager; CirclePageIndicator mIndicator; List<Fragment> fragments; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view =

Change Color TabSelector on v4 ViewPager

梦想与她 提交于 2019-12-21 09:16:43
问题 Is it possible to change color of selected tab on v4 ViewPager? I need to use v4 ViewPager, but I don't find any source to customize it. Just to clarify I need to change the blue color to another one: 回答1: This is the tab indicator. You can change its color by applying different styles. Use Action Bar Style Generator, generate 9patch png files (tab_selected, tab_selected_focused etc.) and add these files + styles to your project. Another approach -> How to change the current tab highlighter

FragmentPagerAdapter inside Fragment

隐身守侯 提交于 2019-12-21 08:55:24
问题 I'm having a bit of trouble implementing a design based around multiple ViewPagers. At a high level, I have a FragmentActivity with just a FrameLayout as it's content. I have 3 different Fragments that I want to display. All 3 are full screen and only 1 will be used at a time. Fragment 1 is a basic fragment with some TextViews and ImageViews. Fragment 2 has a ViewPager and a FragmentPagerAdapter that feeds it several simple fragments. Fragment 3 has a ViewPager and a FragmentPagerAdapter that

FragmentPagerAdapter inside Fragment

梦想与她 提交于 2019-12-21 08:55:10
问题 I'm having a bit of trouble implementing a design based around multiple ViewPagers. At a high level, I have a FragmentActivity with just a FrameLayout as it's content. I have 3 different Fragments that I want to display. All 3 are full screen and only 1 will be used at a time. Fragment 1 is a basic fragment with some TextViews and ImageViews. Fragment 2 has a ViewPager and a FragmentPagerAdapter that feeds it several simple fragments. Fragment 3 has a ViewPager and a FragmentPagerAdapter that

Load only one Fragment in ViewPager

最后都变了- 提交于 2019-12-21 07:48:07
问题 I have used ViewPager with Fragment . But it loads two pages at time. Is there any way to load only one page in viewpager ? 回答1: This might be the thing you are looking for: mPager.setOffscreenPageLimit(n); // where n is the number of offscreen pages you want to load. **The minimum value of it can be "1" as you said. ** check this link and also read the comments. 回答2: setOffScreenPageLimit method has a limit of minimum 1. If you'll try to set smaller limit than this, it will use its default