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.
1 answer
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
|
getItemViewType()
- pavlofff