0

I understood ListView Recycle mechanism very well from How ListView's recycling mechanism works but i don't understand one thing,

If i want to change height of list row then why it only works by setting height dynamically,

For example :

convertView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.FILL_PARENT,80));  

If i define height of row layout in xml it does not change, how it is related to recycle mechanism ?

It is not only for list row height i have seen many cases where attributes of xml does not work but changing them dynamically works well, but how ?

Community
  • 1
  • 1
Piyush Kukadiya
  • 1,880
  • 16
  • 26
  • Can you provide some examples where `setting the attributes of xml` don't work? Also where you inflate that specific item's xml layout. – Simas Oct 10 '14 at 06:36
  • @user3249477 sorry it was my mistake i was trying to inflate layout in wrong way – Piyush Kukadiya Oct 10 '14 at 06:59

1 Answers1

1

I understood, there was a small mistake i was trying to inflate listview layout using

convertView = mInflater.inflate(R.layout.drawer_list_item, null,false);  

above code was the main reason, why attributes of xml were not working. Then i changed it to

convertView = mInflater.inflate(R.layout.drawer_list_item, parent,false);  

Now it is working as expected, sorry but recycle mechanism has nothing to do with xml, i lost there.

Piyush Kukadiya
  • 1,880
  • 16
  • 26