charityhas.blogg.se

Android studio listview with different 2 layouts
Android studio listview with different 2 layouts







android studio listview with different 2 layouts

The first step therefore is to create a model flexible enough to support all the types (i.e Post) and embed a mechanism to determine the type. Keep in mind that each item in this list should be implemented with a common base model. Suppose we wanted to implement a heterogenous list of items in an application. In particular, there are special methods to be overridden within an adapter such as getItemViewType, getViewTypeCount specifically for these situations. To implement a heterogenous list of items, most of the work is done within the adapter. Another example would be Facebook with the many different types of feed items.

android studio listview with different 2 layouts

Examples include a Tumblr client where each post might be an image, text or a video.

android studio listview with different 2 layouts

In other words, different items in the list need to be represented differently. In certain situations, we need to implement a ListView where there are different types of rows in the same list.









Android studio listview with different 2 layouts