Android-根据特定条件跳过View页面中的页面 [英] Android- skipping a page in View pager depending on certain condition

查看:86
本文介绍了Android-根据特定条件跳过View页面中的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

知道我不知道这些页面的位置时,如何根据特定条件在ViewPager中跳过页面,向前或向后滑动.

How to skip a page in a ViewPager depending on certain condition , swiping forward or backward , knowing that i don't know the the position of these pages .

推荐答案

可以.通常情况是,您将创建一个ViewPager并为其设置适配器.此适配器具有getItem(position)方法.您将覆盖此方法,并且对于每个位置,您都将吐出Fragment.在这里,您需要检查状况并发送不同的Fragment.

Yes you can. Normally what happens is that you will create a ViewPager and set an adapter to it. This adapter has the getItem(position) method. You override this method and for each position you will spit out a Fragment. This is the place where you need to check your condition and send out different Fragment.

但是,如果要减少项目数量,还需要调整getCount()以适合您的需求.

However if you are going to reduce the number of items, you also need to adapt the getCount() to suit your needs.

更多信息在这里:

更改ViewPager的计数

动态更新ViewPager吗?

这篇关于Android-根据特定条件跳过View页面中的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆