Currently I am getting this below XML data format from URL-
<Seat>
<ColumnNo>0</ColumnNo>
<Deck>2</Deck>
<Height>2</Height>
<IsAvailable>1</IsAvailable>
<RowNo>0</RowNo>
<SeatLabel>E</SeatLabel>
<Width>1</Width>
</Seat>
<Seat>
<ColumnNo>1</ColumnNo>
<Deck>1</Deck>
<Height>2</Height>
<IsAvailable>1</IsAvailable>
<RowNo>0</RowNo>
<SeatLabel>SL5</SeatLabel>
<Width>1</Width>
</Seat>
<Seat>
<ColumnNo>2</ColumnNo>
<Deck>1</Deck>
<Height>1</Height>
<IsAvailable>1</IsAvailable>
<RowNo>0</RowNo>
<SeatLabel/>
<Width>1</Width>
</Seat>
<Seat>
<ColumnNo>3</ColumnNo>
<Deck>1</Deck>
<Height>2</Height>
<IsAvailable>1</IsAvailable>
<RowNo>0</RowNo>
<SeatLabel>SL1</SeatLabel>
<Width>1</Width>
</Seat>
And i have made image of layout the bus in which i want to make click on vacant seats and disable the seats in which available is 0( <IsAvailable>0</IsAvailable> )
I am confused as to how should I make the below layout and make then populate with the XML data which I am getting.
I am able to parse the data/values from XML in my code....I want that how to make the layout format and fit those XML values to particular seats.
Use Table Layout for designing. You can use this code for designing Refer this link
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:layout_span="4"
android:background="#FFFFFF"
android:gravity="center"
android:text="Table 2"
android:textColor="#000000" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="A"
android:textColor="#000000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="B"
android:textColor="#000000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="C"
android:textColor="#000000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="D"
android:textColor="#000000" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="E"
android:textColor="#000000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="F"
android:textColor="#000000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="G"
android:textColor="#000000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="H"
android:textColor="#000000" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="I"
android:textColor="#000000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="J"
android:textColor="#000000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="K"
android:textColor="#000000" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#FFFFFF"
android:gravity="center"
android:text="L"
android:textColor="#000000" />
</TableRow>
</TableLayout>
</LinearLayout>