开发者

how to display images by using db response like lazylist concept?

开发者 https://www.devze.com 2023-04-05 00:21 出处:网络
i am new developer in android application.i am working on display the images from .net db services.i am communicating with .net web services by using SoapObject class.when i send the request for get t

i am new developer in android application.i am working on display the images from .net db services.i am communicating with .net web services by using SoapObject class.when i send the request for get the images to db then it is returning encoded strings.i am storing those string in an string array.In Lazy load concept they have stored urls into a string array they are passing that array into LazyAdapter class.instead of url string array i am passing response string array as follows

Request:

 String photoXml="<spGetUserPhoto><UserID>148</UserID></spGetUserPhoto>";

Response:

  String response=new ParseXMLString().getUserPhotos(newGeneric().photInfo(photoXml));
  String[] photos=new String[response.size()];
  for(int i=0;i<response.size();i++)
  {
      photos[i]=photoResponse;

   }  

        list=(ListView)findViewById(R.id.list);
        adapter=new LazyAdapter(this, photos);
        list.setAdapter(adapter);

LazyAdapter.java i have written getView method in this class as follows

  public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;


    if(convertView==null)
        vi = inflater.inflate(R.layout.item1, null);

     TextView text=(Tex开发者_开发问答tView)vi.findViewById(R.id.txtViewTitle);;
     ImageView image=(ImageView)vi.findViewById(R.id.imgViewLogo);

     text.setText(messages[position]);
     try {
        imageLoader.DisplayImage(data[position], activity, image);

    } catch (Exception e) {

        e.printStackTrace();
    }

    return vi;

}

From the above code i am viewing images when the response has completed.before view the image i am getting blank screen but not default image.

How to display default image untill completion of response?

plzzz any body help me


  1. you need to use image.setTag(data[position])
  2. In the xml of item1.xml you need to give

0

精彩评论

暂无评论...
验证码 换一张
取 消