How to set position of seat dynamically as response

混江龙づ霸主 提交于 2019-12-24 02:06:27

问题


currently i am create bus ticket book application. in this application i want to set seat as came response of webservice .so problem is that if left side one sleeper seat and right side seater seat then how i arrange seat like below image. currently i am using gridview but i don't know how to achieve. and how to set all dynamically. please suggest if another layout used.

below some code that i used

seatLayout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <RelativeLayout
        android:id="@+id/seatLayoutScroll"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/bottomBarSeatSelection"
        android:background="@color/white" >

        <RelativeLayout
            android:id="@+id/scrollableLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
            <RelativeLayout
                android:id="@+id/seatLegendLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5.0dip"
                android:layout_marginTop="5.0dip"
                android:background="@color/white" >
                <include
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    layout="@layout/bus_seat_indicator_layout" />
            </RelativeLayout>
            <RelativeLayout
                android:id="@+id/seatLayoutLowerMain"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:layout_below="@+id/seatLegendLayout"
                android:layout_centerHorizontal="true"
                android:paddingBottom="5.0dp"
                android:paddingRight="5.0dp"
                android:layout_marginTop="10.0dip">

                <GridView
                    android:id="@+id/gridView1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_below="@+id/driver"
                    android:layout_margin="4dp"
                    android:horizontalSpacing="10dp"
                    android:verticalSpacing="10dp"
                    android:columnWidth="90dp"
                    android:gravity="center"
                    android:stretchMode="columnWidth" >
                </GridView>

                <RelativeLayout
                    android:id="@+id/driver"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_marginRight="20.0dp"
                    android:layout_marginBottom="5.0dp"
                    android:layout_alignRight="@+id/gridView1"
                    android:background="@drawable/steering_icon"
                    android:orientation="horizontal" >
                </RelativeLayout>
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/seatLayoutUpper"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/seatLegendLayout"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10.0dip"
                android:visibility="invisible" />
        </RelativeLayout>
    </RelativeLayout>
    <RelativeLayout
        android:id="@+id/bottomBarSeatSelection"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/white" >
        <include
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            layout="@layout/bus_seat_bottom_layout" />
    </RelativeLayout>

</RelativeLayout>

Using this i achieve below output

but i don't have any idea how to achieve 1st image.


回答1:


I also have been looking for something, but bit more complex than this. But I think this project will help you out with you current requirements. Check these out :-

Seat Booking library
and
Bus Seat Booking

Let me know if it helps.



来源:https://stackoverflow.com/questions/37604922/how-to-set-position-of-seat-dynamically-as-response

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!