<RelativeLayout android:id="@+id/fl_good_img" android:layout_width="60dp" android:layout_height="60dp" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:layout_margin="5dp"> <ImageView android:id="@+id/good_img" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitCenter" android:src="@drawable/ydnei" /> <ImageView android:id="@+id/image_waiting" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitCenter" android:src="@drawable/ydwai" /> </RelativeLayout> 上面是布局代码;接下来是java代码:ImageListener logoListener = new ImageListener() { @Override public void onErrorResponse(VolleyError arg0) {//下载失败的时候加载的写死的图片 if(R.drawable.ic_launcher != 0){ good_img.setImageResource(R.drawable.ic_launcher); } } @Override public void onResponse(ImageContainer arg0, boolean arg1) { if(arg0.getBitmap() != null){//不为null就说明图片已经下载下来了 good_img.setImageBitmap(arg0.getBitmap());//将下载的图片的设置给控件,来展示 image_waiting.clearAnimation(); image_waiting.setVisibility(View.GONE); }else if(R.drawable.ydnei != 0){ good_img.setImageResource(R.drawable.ydnei); } } }; BaseApplacation.sImageLoader.get(item1.image, logoListener);
添加回答
举报
0/150
提交
取消