Tuesday, December 6, 2011

working process of getView and ConvertView:

if you want to load 15 item in listView by using getView method.First time ConvertView is null.It is set all the components.getView is load 7 items first time but it is display six items on the screen and seventh item is not displaying completely.When you are scroll your list then when pointer is reach on seventh item than It is again start recycle this process and hit the getView method and position is starting from sevent to fifteen and again convertView is set.......



@Override
public View getView(int position, View convertView, ViewGroup parent) {
RWLog.i("ProductAdapter :getView :: start");
Log.d("ProductAdapter :getView :: position",""+position);
View view;
Holder holder=new Holder();
if(convertView==null){

RWLog.d("============= null ========== "+position);
convertView = new ProductListRelativeLayoutView(mcontext);
view = convertView;
holder.productImage=(ImageView)view.findViewById(ReadWhereViewConstants.IV_PRODUCT_IMAGE_ID);
holder.productName=(TextView)view.findViewById(ReadWhereViewConstants.TV_PRODUCT_NAME_ID);
holder.productPublisher=(TextView)view.findViewById(ReadWhereViewConstants.TV_PRODUCT_PUBLISHER_ID);
holder.productPrice=(TextView)view.findViewById(ReadWhereViewConstants.TV_PRODUCT_PRICE_ID);
convertView.setTag(holder);


}
holder=(Holder) convertView.getTag();
holder.productName.setText(productList.get(position).getName());
holder.productName.setTextSize(20);
holder.productPublisher.setText(productList.get(position).getPublisher());
holder.productPrice.setText(Float.toString(productList.get(position).getPrice()));
AQuery aq=new AQuery(holder.productImage);
aq.id(holder.productImage).image(productList.get(position).getThumbURL(), true, true, 0, R.drawable.ic_launcher);
RWLog.i("ProductAdapter :getView :: end");
return convertView;

}

No comments:

Post a Comment