I saw a program for the custom listview in the following link http://www.ezzylearning.com/tutorial.aspx?tid=1763429&q=customizing-android-listview-items-with-custom-arra
during the scrolling of ListView
findViewById() (which layout's children is inflated for a row of listview)
is called frequently, which can slow down performance. Even when the Adapter returns an inflated view for recycling
, you still need to look up the elements and update them
. A way around repeated use of findViewById() is to use the view holder design pattern
.
A ViewHolder object stores each of the component views inside the tag field of the Layout
, so you can immediately access them without the need to look them up repeatedly
. First, you need to create a class to hold your exact set of views.
Here is the class in your code
static class WeatherHolder {
ImageView imgIcon;
TextView txtTitle;
}
Yes it is manually created by us in
getView()
u will createObject
of that class and access it
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
WeatherHolder holder = null;
if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new WeatherHolder();
holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);
row.setTag(holder);
}
else
{
holder = (WeatherHolder)row.getTag();
}
//do ur staff
return row;
}
For more info Visit here
http://developer.android.com/training/improving-layouts/smooth-scrolling.html