许许多多的qpp,在启动时会显示一些帮助页或者产品介绍什么的,通常滑动到最后一页时会有一个开始体验的按钮,用来跳转到app的主activity上,但是如果没有?
可以通过如下方法实现:
1.为ViewPager设置监听,OnPageChangeListener
2.实现监听响应
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
public
void
onPageScrollStateChanged(
int
state) {
switch
(state) {
case
ViewPager.SCROLL_STATE_DRAGGING:
misScrolled =
false
;
break
;
case
ViewPager.SCROLL_STATE_SETTLING:
misScrolled =
true
;
break
;
case
ViewPager.SCROLL_STATE_IDLE:
if
(mViewPager.getCurrentItem() == mViewPager.getAdapter().getCount() -
1
&& !misScrolled) {
startActivity(
new
Intent(
this
, MainActivity.
class
));
GuideActivity.
this
.finish();
}
misScrolled =
true
;
break
;
}
|