java.lang.NoSuchMethodError: smoothScrollToPositionFromTop for Froyo ListView?

来源:互联网 发布:上海游奇网络 编辑:程序博客网 时间:2024/06/08 15:29
当出现 java.lang.NoSuchMethodError:时是版本号的问题
if (android.os.Build.VERSION.SDK_INT >= 11){    listView.smoothScrollToPositionFromTop(p, 0); }else if (android.os.Build.VERSION.SDK_INT >= 8){    int firstVisible = listView.getFirstVisiblePosition();    int lastVisible = listView.getLastVisiblePosition();    if (p < firstVisible)        listView.smoothScrollToPosition(p);    else        listView.smoothScrollToPosition(p + lastVisible - firstVisible - 2);}else{    listView.setSelectionFromTop(p, 0);}
这是解决不能在主线程中 通过现成访问网络
if (android.os.Build.VERSION.SDK_INT > 9) {
   StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
     .permitAll().build();
   StrictMode.setThreadPolicy(policy);
  }
0 0
原创粉丝点击