本文整理汇总了Java中android.support.v4.view.ViewPager.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPager.getContext方法的具体用法?Java ViewPager.getContext怎么用?Java ViewPager.getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewPager
的用法示例。
在下文中一共展示了ViewPager.getContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bind
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@BindingAdapter(value = {"fragments", "curIndex"}, requireAll = false)
public static void bind(ViewPager container, final List<? extends Fragment> fragments, int curIndex) {
if(!(container.getContext() instanceof FragmentActivity))
throw new IllegalArgumentException(TAG + "context must instanceof FragmentActivity");
FragmentManager fm = ((FragmentActivity) container.getContext()).getSupportFragmentManager();
if (fragments != null && !fragments.isEmpty()) {
PagerAdapter adapter = container.getAdapter();
if(adapter == null) {
// initialize, fragments are only added once !!!
container.setAdapter(adapter = new FragmentPagerAdapter(fm) {
@Override
public Fragment getItem(int position) {
return fragments.get(position);
}
@Override
public int getCount() {
return fragments.size();
}
});
}
adapter.notifyDataSetChanged();
if(curIndex >= 0 && curIndex < fragments.size())
container.setCurrentItem(curIndex);
}
}
示例2: setDuration
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private static void setDuration(ViewPager pager, int duration) {
try {
FixedSpeedScroller scroller = new FixedSpeedScroller(pager.getContext(), new AccelerateDecelerateInterpolator(), duration);
Field field = ViewPager.class.getDeclaredField("mScroller");
field.setAccessible(true);
field.set(pager, scroller);
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: ViewPageFragmentAdapter
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public ViewPageFragmentAdapter(FragmentManager fm,
PagerSlidingTabStrip pageStrip, ViewPager pager) {
super(fm);
mContext = pager.getContext();
mPagerStrip = pageStrip;
mViewPager = pager;
mViewPager.setAdapter(this);
mPagerStrip.setViewPager(mViewPager);
}
示例4: changeViewPagerScroller
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/**
* 通过反射改变banner的切换速度
*/
private void changeViewPagerScroller(ViewPager mViewPager) {
try {
Field mField = ViewPager.class.getDeclaredField("mScroller");
mField.setAccessible(true);
//用自定义的类替换mScroller
FixedSpeedScroller fixedSpeedScroller = new FixedSpeedScroller(mViewPager.getContext(), new AccelerateInterpolator(), 600);
mField.set(mViewPager, fixedSpeedScroller);
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: ActionsPagerAdapter
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public ActionsPagerAdapter(ViewPager viewPager, List<BaseAction> actions) {
this.context = viewPager.getContext();
this.actions = new ArrayList<>(actions);
this.viewPager = viewPager;
this.gridViewCount = (actions.size() + ITEM_COUNT_PER_GRID_VIEW - 1) / ITEM_COUNT_PER_GRID_VIEW;
}