I take data from the apishki. How do I get a listview through one? I thought everything in one adapter, and then take 2 different item and 2 different adapters.

enter image description here

  • one
    this is a regular listview (or recicedView). Just for views there are two different layouts. And depending on the index, either one or the other is shown. - KoVadim
  • so I need a list to display one on the left one on the right ... etc ... somehow through one to do - Sergo
  • 3
    As far as I can see, this is one list. Just half of the list item is a picture - Vladyslav Matviienko
  • one
    you can use RecyclerView with layout manager StaggeredGridLayoutManager - ZigZag
  • one
    This is one list, just a picture on the left, then on the right. To implement this list, you need to override the method getItemViewType() - pavlofff

1 answer 1

You need to create 1 adapter and 2 layout with markup: 1) left picture and text "one_item_layout" 2) text and right picture "two_item_layout"

Here, keep the method from the adapter (converted for you), replace it.

 @Override public View getView(int position, View convertView, ViewGroup parent) { if ( (position & 1) == 0 ) { //Вставляем лейаут с картинкой слева (если парное число position) convertView = layoutInflater.inflate(R.layout.one_item_layout, parent, false); } else { //Вставляем лейаут с картинкой справа (если не парное число position) convertView = layoutInflater.inflate(R.layout.two_item_layout, parent, false); } return convertView; } 
  • probably the worst solution that works. You can forget about recycling. It's all the same, that stuff all the View at once into ScrollView - Vladyslav Matviienko