R
R
Rizvan Gereykhanov2015-01-19 23:26:24
Android
Rizvan Gereykhanov, 2015-01-19 23:26:24

Can you tell me how to create a ListView with different items?

It is necessary to create a list in one listview with different items, the location of graphics, text and sizes. What is the best way to do this, what are the ways?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
one pavel, 2015-01-20
@Gereykhanov

Let's take a look at what the adapter can do in the documentation
developer.android.com/reference/android/widget/Bas...
it has a getViewTypeCount() method that returns the number of different item types
your adapter has. We redefine it and return the number of types from it.
Nearby we see the description of the getItemViewType(int position) method,
predefine it and write the logic in the body, where you calculate the item type by position.
Now you need to write the getView() work with different items.
Open Google and type in "android listview 2 layouts"
and look at examples of how to inflate several layouts,
save to a tag and restore to change:
www.survivingwithandroid.com/2014/08/android-listv...
android.leocardz.com/multiple-layout-listview

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question