Search code examples
androidperformanceandroid-listviewrecycle

ListView inflating issue


I'm building an sms app, and need to show the view according to Incoming/Outgoing sms. I'm facing the following issue, in my getView(..) I need to know if it's Incoming/Outgoing and then to show the following:

Incoming VIEW

Incoming VIEW

Outgoing VIEW

enter image description here

But i can't think of a way to implement 1 view to handle this (because of the recycling in listview).

I thought of using setLayoutDirection in a LinearLayout, or maybe removeViews and then add them in correct position. Can you please assist me with the best way with the less performance?

Thanks very much


Solution

  • You can override the getViewType method in order to precise how many kind of rows you listview has.

    Have a look here.