Q:

Listview with large number of layout kinds

I am creating a chat app. Messages can be video, photo, text or file + text both for incoming and outgoing. Totally 8 kinds of layout. All messages are in one ListView. 
I read this topic: Here , and it's very easy to organize small number of layouts (2..3), but with large number of layouts (8, 10 or more) I get large ugly switch statements.  How can I organize layouts switching in my adapter's getview()? 

A:

The only other option is to consolidate some of these types into the same layout, which may be a good idea if some of them are quite similar. Otherwise, stick to your switch statement.
If your concern is that you have lots of code within the switch cases, you can always delegate view-binding logic to another method, or to another class (like a ViewHolder).

