I have the below XML from URL and want the below layout with the values filled with the XML data I am getting from URL.
Below is the xml from url
<Seat>
<ColumnNo>0</ColumnNo>
<Deck>2</Deck>
<RowNo>0</RowNo>
<SeatLabel>E</SeatLabel>
</Seat>
<Seat>
<ColumnNo>1</ColumnNo>
<Deck>1</Deck>
<RowNo>0</RowNo>
<SeatLabel>SL5</SeatLabel>
</Seat>
<Seat>
<ColumnNo>2</ColumnNo>
<Deck>1</Deck>
<RowNo>0</RowNo>
<SeatLabel/>
</Seat>
<Seat>
<ColumnNo>3</ColumnNo>
<Deck>1</Deck>
<RowNo>0</RowNo>
<SeatLabel>SL1</SeatLabel>
</Seat>
<Seat>
<ColumnNo>4</ColumnNo>
<Deck>1</Deck>
<RowNo>0</RowNo>
<SeatLabel>SL2</SeatLabel>
</Seat>
<Seat>
<ColumnNo>5</ColumnNo>
<Deck>2</Deck>
<RowNo>0</RowNo>
<SeatLabel>A</SeatLabel>
</Seat>
<Seat>
<ColumnNo>6</ColumnNo>
<Deck>2</Deck>
<RowNo>0</RowNo>
<SeatLabel>B</SeatLabel>
</Seat>
<Seat>
<ColumnNo>2</ColumnNo>
<Deck>1</Deck>
<RowNo>1</RowNo>
<SeatLabel/>
</Seat>
<Seat>
<ColumnNo>0</ColumnNo>
<Deck>2</Deck>
<RowNo>2</RowNo>
<SeatLabel>F</SeatLabel>
</Seat>
with the below code
A.java
public class A extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.addItemDecoration(new MarginDecoration(this));
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new GridLayoutManager(this, 6));
recyclerView.setAdapter(new NumberedAdapter(18));
}
}
MarginDecoration.java
public class MarginDecoration extends RecyclerView.ItemDecoration {
private int margin;
public MarginDecoration(Context context) {
margin = context.getResources().getDimensionPixelSize(R.dimen.item_margin);
}
@Override
public void getItemOffsets(
Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(margin, margin, margin, margin);
}
}
activity_recycler_view.xml
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/item_margin"
android:clipToPadding="false"/>
The all above i did with the help of this Github link