本文整理汇总了Java中android.support.v4.view.ViewPager.setOnPageChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPager.setOnPageChangeListener方法的具体用法?Java ViewPager.setOnPageChangeListener怎么用?Java ViewPager.setOnPageChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewPager
的用法示例。
在下文中一共展示了ViewPager.setOnPageChangeListener方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
public void setViewPager(ViewPager view) {
if (mViewPager == view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
}
PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
示例2: setViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
public void setViewPager(ViewPager view) {
if (mViewPager == view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
}
final PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
示例3: setViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
public void setViewPager(ViewPager view) {
Logger.d("set ViewPager");
if (mViewPager == view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
}
final PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
示例4: onCreate
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Set up the action bar.
final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(android.support.v7.app.ActionBar.NAVIGATION_MODE_TABS);
SectionsPagerAdapter pageAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setAdapter(pageAdapter);
viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
for (int i = 0; i < pageAdapter.getCount(); i++) {
getSupportActionBar().addTab(getSupportActionBar().newTab()
.setText(pageAdapter.getPageTitle(i))
.setTabListener(this));
}
}
示例5: setViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public void setViewPager(ViewPager view) {
if (view == null) {
removeAllViews();
this.mViewPager = null;
} else if (this.mViewPager != view) {
if (this.mViewPager != null) {
this.mViewPager.setOnPageChangeListener(null);
}
if (view.getAdapter() == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
this.mViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
}
示例6: setViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/**
* Sets the associated view pager. Note that the assumption here is that the pager content
* (number of tabs and tab titles) does not change after this call has been made.
*/
public void setViewPager(ViewPager viewPager) {
mTabStrip.removeAllViews();
mViewPager = viewPager;
if (viewPager != null) {
viewPager.setOnPageChangeListener(new InternalViewPagerListener());
populateTabStrip();
}
}
示例7: setViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public void setViewPager(ViewPager pager) {
this.pager = pager;
if (pager.getAdapter() == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
pager.setOnPageChangeListener(pageListener);
notifyDataSetChanged();
}
示例8: setViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public void setViewPager(ViewPager view) {
if (this.mViewPager != view) {
if (this.mViewPager != null) {
this.mViewPager.setOnPageChangeListener(null);
}
if (view.getAdapter() == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
this.mViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
}
示例9: setViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public void setViewPager(ViewPager pager) {
this.pager = pager;
if (pager.getAdapter() == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
pager.setOnPageChangeListener(pageListener);
notifyDataSetChanged();
}
示例10: setViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public void setViewPager(ViewPager pager) {
mViewPager = pager;
PagerAdapter adp = pager == null ? null : pager.getAdapter();
if (adp != null) {
if (adp instanceof ItemProvider) {
mITabProvider = (ItemProvider) adp;
}
pager.setOnPageChangeListener(mViewPageListener);
}
notifyDataSetChanged();
}
示例11: initControl
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void initControl(){
/*set it to be no title*/
requestWindowFeature(Window.FEATURE_NO_TITLE);
/*set it to be full screen*/
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_image_show);
iamgeViewPager = (ViewPager) findViewById(R.id.image_pager);
LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
iamgeViewPager.setLayoutParams(params);
iamgeViewPager.setOnPageChangeListener(pageChangeListener);
guidPview = (ViewGroup) findViewById(R.id.guid_point);
setImageViewPager(false);
delButton = (Button) findViewById(R.id.b_right_id);
if (getIntent().getStringExtra("delete").equals("delete")) {
delButton.setVisibility(View.GONE);
}
delButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mImages.size() > 1) {
mImages.remove(cus);
GlobalData.setImagesList(mImages);
setImageViewPager(false);
} else {
mImages.remove(0);
GlobalData.setImagesList(mImages);
Intent intent = new Intent();
setResult(CodeDefine.IMAGE_SHOW_RESULT, intent);
finish();
}
}
});
}
示例12: initViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void initViewPager() {
mViewPager = (ViewPager)findViewById(R.id.mViewPager);
mAdapetr = new BaseFragmentPagerAdapter(
getSupportFragmentManager());
mViewPager.setOffscreenPageLimit(1);
mViewPager.setAdapter(mAdapetr);
mViewPager.setOnPageChangeListener(pageListener);
}
示例13: onCreateView
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_app, null);
mViewPager = (ViewPager) view.findViewById(R.id.app_view_pager);
pointer = (TextView) view.findViewById(R.id.app_pointer);
initAnimation();
pointer.startAnimation(rotation);
initAllApp();
mViewPager.setOnPageChangeListener(pageChangeListener);
return view;
}
示例14: onCreate
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_detail);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
getSupportLoaderManager().initLoader(0, null, this);
//Postpone transition here
ActivityCompat.postponeEnterTransition(this);
mPager = (ViewPager) findViewById(R.id.pager);
mPager.setPageTransformer(false, new ParallaxPagerTransformer(R.id.image));
mPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
mPager.setPageMargin((int) TypedValue
.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
mPager.setPageMarginDrawable(new ColorDrawable(0x22000000));
mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageScrollStateChanged(int state) {
super.onPageScrollStateChanged(state);
}
@Override
public void onPageSelected(int position) {
if (mCursor != null) {
mCursor.moveToPosition(position);
}
mSelectedItemId = mCursor.getLong(GalleryLoader.Query.COLUMN_IMAGE_ID);
}
});
if (savedInstanceState == null) {
if (getIntent() != null && getIntent().getData() != null) {
mStartId = GalleryContract.GalleryEntry.getItemId(getIntent().getData());
mSelectedItemId = mStartId;
}
}
}