I am working on reuse of cell and currently i am working in getview method of adapter and i got one problem that my getview method called 9 times but it should call only 5 times at the starting of app because i am displaying only 5 rows.
public View getView(int position, View view, ViewGroup viewgroup)
{
ViewHolder holder=null;
if(view==null)
{
view = inflater.inflate(R.layout.my_row_layout, viewgroup, false);
Log.d("Testing","View is nuLL");
holder.thumbnils = (ImageView)view.findViewById(R.id.Thumbnils);
holder.hover =(ImageButton)view.findViewById(R.id.hover);
holder.title =(TextView)view.findViewById(R.id.title);
holder.hoveroverlay =(ImageView)view.findViewById(R.id.hoveroverlay);
}view.setTag(holder);
}
else
{
Log.d("Testing","view is not null");
holder = (ViewHolder) view.getTag();
}
return view;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
if(data.size()%NumberOfCell==0)
{
//return Number rows in listview
return data.size() /NumberOfCell;
}
else
{
//If total number of videos are ODD than display one row extra for remaining videos
return data.size() /NumberOfCell+1;
}
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 1;
}
Here is my xml
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/imageView2"
android:layout_alignLeft="@+id/linearLayout1"
android:layout_below="@+id/linearLayout1"
android:scrollbars="none"
android:divider="#000000"
android:dividerHeight="2dp"
>
</ListView>
</RelativeLayout>
Please help me guys
Thank you.........
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…