이미 URL에서로드 된 이미지가 포함 된 목록보기가 있습니다. 로드 중일 때 각 이미지 에 회전 원과 같은 것을 추가하고 싶습니다. 지금은로드되기 전에로드되는 이미지를 대체하기 위해 기본값을 사용했습니다. 여기서 주로 발견하는 것은 모든 클래스가 AsyncTask를 확장한다는 것입니다. 글쎄, 내가 가진 것은 다음과 같다 :이미지가로드되는 동안 서클 애니메이션로드 추가
나는 json을 파싱하는 활동이있다.
//constructor
public MyCustomAdapter (Context c, List<RowItem> items){
this.context = c;
this.sRowItems = items;
imageLoader=new ImageLoader(c.getApplicationContext());
}
.
.
.
public View getView(int position, View convertView, ViewGroup parent){
ViewHolder holder = null;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if(convertView == null){
convertView = inflater.inflate(R.layout.list_layout, null);
holder = new ViewHolder();
holder.txtName = (TextView) convertView.findViewById(R.id.name);
holder.txtDesc = (TextView) convertView.findViewById(R.id.desc);
holder.imageView = (ImageView) convertView.findViewById(R.id.prof_pic);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
RowItem sItem = (RowItem) getItem(position);
holder.txtName.setText(sItem.getShopName());
holder.txtDesc.setText(sItem.getShopDesc());
imageLoader.DisplayImage(sItem.getImageUrl(), holder.imageView);
return convertView;
}
그럼 난 내 이미지 로더 클래스가 : 그럼 내가 BaseAdapter를 확장하는 MyCustomAdapter 있습니다. 그래서 AsyncTask 대신, 나는 일반적인 자바 쓰레드를 사용했다. public class ImageLoader {
MemoryCache memoryCache=new MemoryCache();
FileCache fileCache;
private Map<ImageView, String> imageViews=Collections.synchronizedMap(new WeakHashMap<ImageView, String>());
ExecutorService executorService;
public ImageLoader(Context context){
fileCache=new FileCache(context);
executorService=Executors.newFixedThreadPool(5);
}
final int stub_id=R.drawable.ic_launcher;
public void DisplayImage(String url, ImageView imageView)
{
imageViews.put(imageView, url);
Bitmap bitmap=memoryCache.get(url);
if(bitmap!=null)
imageView.setImageBitmap(bitmap);
else
{
queuePhoto(url, imageView);
imageView.setImageResource(stub_id);
}
}
private void queuePhoto(String url, ImageView imageView)
{
PhotoToLoad p=new PhotoToLoad(url, imageView);
executorService.submit(new PhotosLoader(p));
}
내가
ProgressDialog mDialog = new ProgressDialog(getApplicationContext());
를 사용하는 유래 여기에 답변을 보았다하지만 난 내하여 ImageLoader 클래스에 배치 할 때 내 코드와 함께 작동하지 않았다 : 그것의 부분이있다. 이 로딩 애니메이션 원을 구현하는 데 어려움을 겪고 있습니다. 도움주세요. 매우 감사합니다. 사전 실행에
좋아요, 제가 이걸 쏠 게요 .. – elL