Home > Mobile >  Similar to chat, a variety of layout of the inside of the service, how to easy
Similar to chat, a variety of layout of the inside of the service, how to easy

Time:11-03

Customer-service chat screen there are many kinds of layout, such as images, text, lists, and so on nearly dozens, in a ListView or RecyclerView, each write words, can cause very bloated complex code, getItemViewType inside to return to the layout of the different types, onCreateViewHolder to load a different layout, in onBindViewHolder again according to the different viewholder to load the data, this way to write the code is very complicated, and is there any easy way, can the code structure is clear, not bloated,
As well as how to handle the data, I the current approach is to store each item used depending on the type of layout data, load, judge what is the layout of the type, then go to parse different data structure, and finally to load, always feel like this can lead to poor performance, what good solution, please?

CodePudding user response:

The best solution is to abandon the android, build a belongs to own barbecue,

CodePudding user response:

That didn't also way, can you take these functions encapsulated,
An adapter via the add your interface to realize each function independently

CodePudding user response:

The factory pattern, know
  • Related