尝试更新图像视图传呼机时,我低于ANR。有人有主意吗?下面是我的代码。我怀疑当我做setcurrentItem得到这个ANR : Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 5.

private void setRelavantColourPic(ValueList valueList){
   if(valueList.getPictureId() != 0 && productImages != null && productImages.size() > 0){
       i = 0;

       for (ProductPictureList productPictureList : productImages ){
           int pictureId =  Integer.parseInt(productPictureList.getPictureId());
           i ++;
           if(pictureId == valueList.getPictureId()){
               foundIndex = i-1;
           }
       }



       mDelayHandler.postDelayed(
               mRunnable =   new Runnable() {
                   @Override
                   public void run() {
                       mProductImageViewPager.setCurrentItem(foundIndex);
                   }
               }, 1);
     //  mDelayHandler.post(mRunnable);

   }
}

最佳答案

我认为这是递归和阻塞主线程。尝试删除以下语句,

mDelayHandler.post(mRunnable);


它会工作。

07-27 13:58