本文整理匯總了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;
}