用android中的viewpager适配器有没有办法减慢滚动速度?
你知道,我一直在看这段代码.我无法弄清楚我错了什么.
try{
Field mScroller = mPager.getClass().getDeclaredField("mScroller");
mScroller.setAccessible(true);
Scroller scroll = new Scroller(cxt);
Field scrollDuration = scroll.getClass().getDeclaredField("mDuration");
scrollDuration.setAccessible(true);
scrollDuration.set(scroll, 1000);
mScroller.set(mPager, scroll);
}catch (Exception e){
Toast.makeText(cxt, "something happened", Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud)
它没有改变什么,但没有例外发生?
android ×1