您的位置:首页 > 移动开发 > Android开发

ListView进行平滑的移动

2014-02-04 16:06 309 查看
由于在低版本的Android中是不支持平滑移动,所以需要用反射机制去解决这个问题

smoothToDes(int smoothDistance,int selection) {
try {
if (Integer.parseInt(Build.VERSION.SDK) > 3) {
Method smoothMethod = ListView.this.getMethod("smoothScrollToPosition",new Class[]{Integer.class});
Object[] methodArray = new Object[1];
methodArray[0] = Integer.valueOf(smoothDistance);
smoothMethod.invoke(ListView.this,methodArray);
} else {
setSelection(selection);
}
} catch(Exception e) {
setSelection(selection);
}

}


这样就能够解决不同的版本
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  移动 listview android