要实现的效果是点击加按钮就购买分数自动加一,同时计算合计的总计

先共享一份colors.xml的数据,比较全面,可以根据需要添加

<?xml version="1.0" encoding="UTF-8"?>
<resources><color name="popup_main_background">#b0000000</color><color name="choose_eara_item_press_color">#f4f4f4</color><color name="no_color">#00000000</color><color name="top_bar_normal_bg">#4ebcd3</color><color name="bottom_bar_normal_bg">#2D2F31</color><color name="bottom_text_color_normal">#ffffff</color><color name="divider_list">#cccccc</color><color name="common_bg">#fcfcfc</color><color name="topbar_bg">#0099ff</color><color name="tab_bg">#f9f9f9</color><color name="tab_text_bg">#bababa</color><color name="line_bg">#f0f0f0</color>    <!-- 特别提示、重要数据等文字颜色:#004199     蓝色       “cor1 --><!--  <color name="cor1">#004299</color>--><color name="cor1">#0099ff</color><color name="cor2">#7cbe28</color>   <!-- 背景 --><color name="cor4">#fafafa</color><color name="cor5">#cccccc</color><color name="cor6">#999999</color><color name="cor7">#666666</color><color name="cor8">#333333</color><color name="blue_start">#00338B</color><color name="blue_center">#003F97</color><color name="blue_end">#0B4CA4</color><color name="yellow_text">#f08300</color><!-- 青色按下效果颜色 --><color name="green_start">#61A30C</color><color name="green_center">#80C22C</color><color name="green_end">#95D741</color><!-- 右边菜单点击颜色 --><color name="right_menu_unpressed">#CDCEC9</color><color name="right_menu_pressed">#C3C3C3</color><color name="menu_item_press">#2e000000</color><color name="page_backgroup">#f2f2f2</color><!-- 橙色 --><color name="orange_color">#de6838</color><!-- 灰色 --><color name="grey_color1">#333333</color><color name="grey_color2">#666666</color><color name="grey_color3">#999999</color><!-- footer、标题、下拉列表、按钮等文字颜色:#fafafa  白色 “cor4” --><color name="white2">#fafafa</color><!-- 正常略黑的位子颜色 --><color name="textcolor">#666666</color><!-- 所有线框的标准色 --><color name="linecolor">#cccccc</color><color name="colorhint">#cccccc</color><color name="shape_start">#02367D</color><color name="shape_end">#0F438A</color><color name="light_gray">#EFEFEF</color><color name="red1">#EB321B</color><!-- capture --><color name="viewfinder_mask">#60000000</color><color name="result_view">#b0000000</color><color name="viewfinder_frame">#ff000000</color><color name="viewfinder_laser">#ffff0000</color><color name="possible_result_points">#c0ffff00</color><color name="linkblue">#33B5E5</color><!-- 白色 --><color name="bg_White">#FFFFFF</color><!-- 黑色 --><color name="bg_Black">#000000</color><!-- 灰色 --><color name="bg_Gray">#CCCCCC</color><!-- 浅灰色 --><color name="bg_Gray_light">#EEEEEE</color><!-- 白色 --><color name="tv_White">#FFFFFF</color><!-- 黑色 --><color name="tv_Black">#000000</color><!-- 红色 --><color name="tv_Red">#CC0000</color><!-- 灰色 --><color name="tv_Gray">#CCCCCC</color><color name="white">#FFFFFF</color><!-- 白色 --><color name="ivory">#FFFFF0</color><!-- 象牙色 --><color name="lightyellow">#FFFFE0</color><!-- 亮黄色 --><color name="yellow">#FFFF00</color><!-- 黄色 --><color name="snow">#FFFAFA</color><!-- 雪白色 --><color name="floralwhite">#FFFAF0</color><!-- 花白色 --><color name="lemonchiffon">#FFFACD</color><!-- 柠檬绸色 --><color name="cornsilk">#FFF8DC</color><!-- 米绸色 --><color name="seashell">#FFF5EE</color><!-- 海贝色 --><color name="lavenderblush">#FFF0F5</color><!-- 淡紫红 --><color name="papayawhip">#FFEFD5</color><!-- 番木色 --><color name="blanchedalmond">#FFEBCD</color><!-- 白杏色 --><color name="mistyrose">#FFE4E1</color><!-- 浅玫瑰色 --><color name="bisque">#FFE4C4</color><!-- 桔黄色 --><color name="moccasin">#FFE4B5</color><!-- 鹿皮色 --><color name="navajowhite">#FFDEAD</color><!-- 纳瓦白 --><color name="peachpuff">#FFDAB9</color><!-- 桃色 --><color name="gold">#FFD700</color><!-- 金色 --><color name="pink">#FFC0CB</color><!-- 粉红色 --><color name="lightpink">#FFB6C1</color><!-- 亮粉红色 --><color name="orange">#FFA500</color><!-- 橙色 --><color name="lightsalmon">#FFA07A</color><!-- 亮肉色 --><color name="darkorange">#FF8C00</color><!-- 暗桔黄色 --><color name="coral">#FF7F50</color><!-- 珊瑚色 --><color name="hotpink">#FF69B4</color><!-- 热粉红色 --><color name="tomato">#FF6347</color><!-- 西红柿色 --><color name="orangered">#FF4500</color><!-- 红橙色 --><color name="deeppink">#FF1493</color><!-- 深粉红色 --><color name="fuchsia">#FF00FF</color><!-- 紫红色 --><color name="magenta">#FF00FF</color><!-- 红紫色 --><color name="red">#FF0000</color><!-- 红色 --><color name="oldlace">#FDF5E6</color><!-- 老花色 --><color name="lightgoldenrodyellow">#FAFAD2</color><!-- 亮金黄色 --><color name="linen">#FAF0E6</color><!-- 亚麻色 --><color name="antiquewhite">#FAEBD7</color><!-- 古董白 --><color name="salmon">#FA8072</color><!-- 鲜肉色 --><color name="ghostwhite">#F8F8FF</color><!-- 幽灵白 --><color name="mintcream">#F5FFFA</color><!-- 薄荷色 --><color name="whitesmoke">#F5F5F5</color><!-- 烟白色 --><color name="beige">#F5F5DC</color><!-- 米色 --><color name="wheat">#F5DEB3</color><!-- 浅黄色 --><color name="sandybrown">#F4A460</color><!-- 沙褐色 --><color name="azure">#F0FFFF</color><!-- 天蓝色 --><color name="honeydew">#F0FFF0</color><!-- 蜜色 --><color name="aliceblue">#F0F8FF</color><!-- 艾利斯兰 --><color name="khaki">#F0E68C</color><!-- 黄褐色 --><color name="lightcoral">#F08080</color><!-- 亮珊瑚色 --><color name="palegoldenrod">#EEE8AA</color><!-- 苍麒麟色 --><color name="violet">#EE82EE</color><!-- 紫罗兰色 --><color name="darksalmon">#E9967A</color><!-- 暗肉色 --><color name="lavender">#E6E6FA</color><!-- 淡紫色 --><color name="lightcyan">#E0FFFF</color><!-- 亮青色 --><color name="burlywood">#DEB887</color><!-- 实木色 --><color name="plum">#DDA0DD</color><!-- 洋李色 --><color name="gainsboro">#DCDCDC</color><!-- 淡灰色 --><color name="crimson">#DC143C</color><!-- 暗深红色 --><color name="palevioletred">#DB7093</color><!-- 苍紫罗兰色 --><color name="goldenrod">#DAA520</color><!-- 金麒麟色 --><color name="orchid">#DA70D6</color><!-- 淡紫色 --><color name="thistle">#D8BFD8</color><!-- 蓟色 --><color name="lightgray">#D3D3D3</color><!-- 亮灰色 --><color name="lightgrey">#D3D3D3</color><!-- 亮灰色 --><color name="tan">#D2B48C</color><!-- 茶色 --><color name="chocolate">#D2691E</color><!-- 巧可力色 --><color name="peru">#CD853F</color><!-- 秘鲁色 --><color name="indianred">#CD5C5C</color><!-- 印第安红 --><color name="mediumvioletred">#C71585</color><!-- 中紫罗兰色 --><color name="silver">#C0C0C0</color><!-- 银色 --><color name="darkkhaki">#BDB76B</color><!-- 暗黄褐色 --><color name="rosybrown">#BC8F8F</color><!-- 褐玫瑰红 --><color name="mediumorchid">#BA55D3</color><!-- 中粉紫色 --><color name="darkgoldenrod">#B8860B</color><!-- 暗金黄色 --><color name="firebrick">#B22222</color><!-- 火砖色 --><color name="powderblue">#B0E0E6</color><!-- 粉蓝色 --><color name="lightsteelblue">#B0C4DE</color><!-- 亮钢兰色 --><color name="paleturquoise">#AFEEEE</color><!-- 苍宝石绿 --><color name="greenyellow">#ADFF2F</color><!-- 黄绿色 --><color name="lightblue">#ADD8E6</color><!-- 亮蓝色 --><color name="darkgray">#A9A9A9</color><!-- 暗灰色 --><color name="darkgrey">#A9A9A9</color><!-- 暗灰色 --><color name="brown">#A52A2A</color><!-- 褐色 --><color name="sienna">#A0522D</color><!-- 赭色 --><color name="darkorchid">#9932CC</color><!-- 暗紫色 --><color name="palegreen">#98FB98</color><!-- 苍绿色 --><color name="darkviolet">#9400D3</color><!-- 暗紫罗兰色 --><color name="mediumpurple">#9370DB</color><!-- 中紫色 --><color name="lightgreen">#90EE90</color><!-- 亮绿色 --><color name="darkseagreen">#8FBC8F</color><!-- 暗海兰色 --><color name="saddlebrown">#8B4513</color><!-- 重褐色 --><color name="darkmagenta">#8B008B</color><!-- 暗洋红 --><color name="darkred">#8B0000</color><!-- 暗红色 --><color name="blueviolet">#8A2BE2</color><!-- 紫罗兰蓝色 --><color name="lightskyblue">#87CEFA</color><!-- 亮天蓝色 --><color name="skyblue">#87CEEB</color><!-- 天蓝色 --><color name="gray">#808080</color><!-- 灰色 --><color name="grey">#808080</color><!-- 灰色 --><color name="olive">#808000</color><!-- 橄榄色 --><color name="purple">#800080</color><!-- 紫色 --><color name="maroon">#800000</color><!-- 粟色 --><color name="aquamarine">#7FFFD4</color><!-- 碧绿色 --><color name="chartreuse">#7FFF00</color><!-- 黄绿色 --><color name="lawngreen">#7CFC00</color><!-- 草绿色 --><color name="mediumslateblue">#7B68EE</color><!-- 中暗蓝色 --><color name="lightslategray">#778899</color><!-- 亮蓝灰 --><color name="lightslategrey">#778899</color><!-- 亮蓝灰 --><color name="slategray">#708090</color><!-- 灰石色 --><color name="slategrey">#708090</color><!-- 灰石色 --><color name="olivedrab">#6B8E23</color><!-- 深绿褐色 --><color name="slateblue">#6A5ACD</color><!-- 石蓝色 --><color name="dimgray">#696969</color><!-- 暗灰色 --><color name="dimgrey">#696969</color><!-- 暗灰色 --><color name="mediumaquamarine">#66CDAA</color><!-- 中绿色 --><color name="cornflowerblue">#6495ED</color><!-- 菊兰色 --><color name="cadetblue">#5F9EA0</color><!-- 军兰色 --><color name="darkolivegreen">#556B2F</color><!-- 暗橄榄绿 --><color name="indigo">#4B0082</color><!-- 靛青色 --><color name="mediumturquoise">#48D1CC</color><!-- 中绿宝石 --><color name="darkslateblue">#483D8B</color><!-- 暗灰蓝色 --><color name="steelblue">#4682B4</color><!-- 钢兰色 --><color name="royalblue">#4169E1</color><!-- 皇家蓝 --><color name="turquoise">#40E0D0</color><!-- 青绿色 --><color name="mediumseagreen">#3CB371</color><!-- 中海蓝 --><color name="limegreen">#32CD32</color><!-- 橙绿色 --><color name="darkslategray">#2F4F4F</color><!-- 暗瓦灰色 --><color name="darkslategrey">#2F4F4F</color><!-- 暗瓦灰色 --><color name="seagreen">#2E8B57</color><!-- 海绿色 --><color name="forestgreen">#228B22</color><!-- 森林绿 --><color name="lightseagreen">#20B2AA</color><!-- 亮海蓝色 --><color name="dodgerblue">#1E90FF</color><!-- 闪兰色 --><color name="midnightblue">#191970</color><!-- 中灰兰色 --><color name="aqua">#00FFFF</color><!-- 浅绿色 --><color name="cyan">#00FFFF</color><!-- 青色 --><color name="springgreen">#00FF7F</color><!-- 春绿色 --><color name="lime">#00FF00</color><!-- 酸橙色 --><color name="mediumspringgreen">#00FA9A</color><!-- 中春绿色 --><color name="darkturquoise">#00CED1</color><!-- 暗宝石绿 --><color name="deepskyblue">#00BFFF</color><!-- 深天蓝色 --><color name="darkcyan">#008B8B</color><!-- 暗青色 --><color name="teal">#008080</color><!-- 水鸭色 --><color name="green">#7cbe28</color><!-- 绿色 --><color name="darkgreen">#006400</color><!-- 暗绿色 --><color name="blue">#004299</color><!-- 蓝色 --><color name="mediumblue">#0000CD</color><!-- 中兰色 --><color name="darkblue">#00008B</color><!-- 暗蓝色 --><color name="navy">#000080</color><!-- 海军色 --><color name="black">#000000</color><!-- 黑色 -->
</resources>

自定义的dimens.xml

<?xml version="1.0" encoding="utf-8"?>
<resources><!-- Default screen margins, per the Android Design guidelines. --><dimen name="image_thumbnail_size">100dp</dimen><dimen name="image_thumbnail_spacing">1dp</dimen><dimen name="height_top_bar">48dp</dimen><dimen name="activity_horizontal_margin">16dp</dimen><dimen name="activity_vertical_margin">16dp</dimen><dimen name="f26">18sp</dimen><dimen name="f21">15sp</dimen><dimen name="f18">13sp</dimen><dimen name="f16">11sp</dimen><dimen name="f13">9sp</dimen><dimen name="f24">17sp</dimen><dimen name="spa10">67dp</dimen><dimen name="spa74">50dp</dimen><dimen name="spa72">49dp</dimen><dimen name="spa78">53dp</dimen><dimen name="spa82">55dp</dimen><dimen name="spa66">44dp</dimen><dimen name="spa68">45dp</dimen><dimen name="spa60">40dp</dimen><dimen name="spa100">67dp</dimen><dimen name="spa120">80dp</dimen><dimen name="spa600">400dp</dimen><dimen name="spa150">100dp</dimen><dimen name="spa180">120dp</dimen><dimen name="spa48">45dp</dimen><dimen name="spa33">30dp</dimen><dimen name="spa22">16dp</dimen><dimen name="spa390">270dp</dimen><dimen name="spa90">60dp</dimen><dimen name="spa18">12dp</dimen><dimen name="spa15">10dp</dimen><dimen name="spa3">3dp</dimen><dimen name="spa230">155dp</dimen><dimen name="spa260">174dp</dimen><dimen name="spa130">87dp</dimen><dimen name="contract">72dp</dimen><!-- 投资列表中checkbox间距 --><dimen name="investment_chekbox_pandding">6dp</dimen><!-- 边距 --><dimen name="pad5">3dp</dimen><dimen name="pad1">4dp</dimen><dimen name="pad3">6dp</dimen><dimen name="pad4">12dp</dimen><dimen name="pad15">10dp</dimen><dimen name="pad20">14dp</dimen><dimen name="pad9">6dp</dimen><dimen name="pad12">9dp</dimen><!-- 字体大小 --><dimen name="txt_8">8sp</dimen><dimen name="txt_10">10sp</dimen><dimen name="txt_12">12sp</dimen><dimen name="txt_14">14sp</dimen><dimen name="txt_16">16sp</dimen><dimen name="txt_18">18sp</dimen><dimen name="txt_20">20sp</dimen><dimen name="txt_22">22sp</dimen><dimen name="txt_24">24sp</dimen><dimen name="txt_26">26sp</dimen><dimen name="txt_28">28sp</dimen></resources>

自定义的drawable

text_angle_gray.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" ><!-- 连框颜色值 --><item><shape><solid android:color="#CCCCCC" /></shape></item><!-- 主体背景颜色值 --><itemandroid:bottom="1dp"android:top="1dp"android:left="1dp"><!-- 边框里面背景颜色 白色 --><shape><solid android:color="@color/page_backgroup" /></shape></item></layer-list>

text_angle.xml,是实现圆角效果的

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"><solid android:color="#FFFFFFFF"/><corners android:radius="0dp"/><stroke android:color="#CCCCCC"android:width="0.01dp" />
</shape>

text_angle_right.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" ><!-- 连框颜色值 --><item><shape><solid android:color="#CCCCCC" /></shape></item><!-- 主体背景颜色值 --><itemandroid:bottom="1dp"android:top="1dp"android:right="1dp"><!-- 边框里面背景颜色 白色 --><shape><solid android:color="@color/page_backgroup" /></shape></item></layer-list>

然后,实现这个ui

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@color/bg_White"android:focusable="true"android:focusableInTouchMode="true" ><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="@dimen/height_top_bar"android:background="@color/top_bar_normal_bg"android:gravity="center_vertical" ><TextViewandroid:id="@+id/tv_back"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_alignParentLeft="true"android:background="@drawable/common_tab_bg"android:clickable="true"android:drawableLeft="@drawable/btn_titlebar_back"android:gravity="center"android:scaleType="centerInside"android:text="@string/back"android:textColor="@color/white" /><TextViewandroid:id="@+id/message_title"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="@string/reserve"android:textColor="@color/bottom_text_color_normal"android:textSize="18sp" /></RelativeLayout><Viewandroid:layout_width="match_parent"android:layout_height="1dp"android:background="@color/bg_Gray" /><ScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginTop="50dp" ><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical" ><TextViewandroid:id="@+id/tv_intro"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="2.64"android:paddingBottom="15dp"android:paddingLeft="10dp"android:paddingTop="15dp"android:textColor="@color/tv_Black" /><Viewandroid:layout_width="match_parent"android:layout_height="1dp"android:layout_marginLeft="8dp"android:layout_marginRight="8dp"android:background="@drawable/line" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="38dp"android:orientation="horizontal" ><TextViewandroid:id="@+id/iv_adapter_list_pic"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_margin="5dp"android:scaleType="centerCrop"android:text="出游日期:"android:textColor="@color/black" /><LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:gravity="center"android:orientation="vertical" ><EditTextandroid:id="@+id/et_time"android:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="15dp"android:paddingRight="15dp"android:textColor="@color/tv_Black" ></EditText></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:layout_marginRight="5dp"android:orientation="vertical" ></LinearLayout></LinearLayout><Viewandroid:layout_width="match_parent"android:layout_height="1dp"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:layout_marginTop="10dp"android:background="@drawable/line" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="42dp"android:gravity="center"android:orientation="horizontal" ><LinearLayoutandroid:id="@+id/linearLayout1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:layout_marginRight="15dp"android:orientation="horizontal" ><TextViewandroid:id="@+id/tv_reduce"android:layout_width="25dp"android:layout_height="25dp"android:background="@drawable/text_angle_gray"android:gravity="center"android:text="-"android:textColor="@color/grey_color1"android:textSize="@dimen/txt_12" /><TextViewandroid:id="@+id/tv_num"android:layout_width="25dp"android:layout_height="25dp"android:background="@drawable/text_angle"android:gravity="center"android:singleLine="true"android:text="1"android:textColor="@color/grey_color1"android:textSize="@dimen/txt_12" /><TextViewandroid:id="@+id/tv_add"android:layout_width="25dp"android:layout_height="25dp"android:background="@drawable/text_angle_right"android:gravity="center"android:text="+"android:textColor="@color/grey_color1"android:textSize="@dimen/txt_12" /></LinearLayout><TextViewandroid:id="@+id/tv_1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_centerVertical="true"android:text="购买份数:"android:textColor="@color/tv_Black" /><TextViewandroid:id="@+id/tv_price"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignBaseline="@+id/tv_1"android:layout_alignBottom="@+id/tv_1"android:layout_marginLeft="52dp"android:layout_toRightOf="@+id/tv_1"android:singleLine="true"android:text="¥308.00"android:textColor="@color/orange_color"android:textSize="@dimen/txt_14"android:textStyle="bold" /></RelativeLayout><Viewandroid:layout_width="match_parent"android:layout_height="5dp"android:background="@color/bg_Gray_light" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:gravity="center"android:orientation="horizontal" ><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:layout_weight="1"android:text="取票信息"android:textColor="@color/tv_Black" /></LinearLayout><Viewandroid:layout_width="match_parent"android:layout_height="1dp"android:layout_marginLeft="8dp"android:layout_marginRight="8dp"android:background="@drawable/line" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="55dp"android:gravity="center_vertical"android:paddingBottom="4dp"android:paddingTop="25dp" ><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:layout_marginLeft="21dp"android:text="姓名:"android:textColor="@color/tv_Black"android:textSize="15sp" /><EditTextandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignTop="@+id/textView1"android:layout_marginLeft="29dp"android:layout_toRightOf="@+id/textView1"android:background="@drawable/bg_menu_edit"android:gravity="center_vertical"android:hint="要与证件一样哦"android:textSize="16dp" /></RelativeLayout><Viewandroid:layout_width="match_parent"android:layout_height="1dp"android:layout_marginLeft="8dp"android:layout_marginRight="8dp"android:background="@drawable/line" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="55dp"android:paddingBottom="4dp"android:paddingTop="25dp" ><TextViewandroid:id="@+id/textView2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:layout_marginLeft="21dp"android:text="证件:"android:textColor="@color/tv_Black"android:textSize="15sp" /><EditTextandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignTop="@+id/textView2"android:layout_marginLeft="29dp"android:layout_toRightOf="@+id/textView2"android:background="@drawable/bg_menu_edit"android:hint="请输入证件号码"android:textSize="16dp" /></RelativeLayout><Viewandroid:layout_width="match_parent"android:layout_height="5dp"android:background="@color/bg_Gray_light" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="68dp"android:layout_weight="49.46"android:background="@color/bg_Gray_light"android:gravity="center"android:orientation="horizontal" ></LinearLayout></LinearLayout></ScrollView><LinearLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:layout_alignParentBottom="true"android:background="@color/bg_White"android:orientation="horizontal" ><LinearLayoutandroid:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="2.5"android:background="@color/bg_White"android:gravity="center_vertical"android:orientation="horizontal" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="5dp"android:text="合计:"android:textColor="@color/purple"android:textSize="16sp"android:textStyle="bold" /><TextViewandroid:id="@+id/tv_total_price"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="¥0.00"android:textColor="@color/purple"android:textSize="16sp"android:textStyle="bold" /></LinearLayout><TextViewandroid:id="@+id/tv_clear"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:background="@color/orange"android:clickable="true"android:gravity="center"android:text="清空"android:textColor="#FAFAFA" /><TextViewandroid:id="@+id/tv_go_to_pay"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:background="@color/crimson"android:clickable="true"android:gravity="center"android:text="结算(0)"android:textColor="#FAFAFA" /></LinearLayout></RelativeLayout>

业务实现

package com.tsc.activities;import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;import com.tsc.Constant;
import com.tsc.fragment.CalendarFragment;
import com.tsc.service.AddOrderService;/*** 预定旅游服务的Activity类*  */
public class ReserveActivity extends Activity implements OnClickListener{private TextView tv_back;//返回的TextViewprivate TextView tv_price;//单价的TextViewprivate TextView tv_total_price;//总价的TextViewprivate TextView tv_clear;//清空的TextViewprivate TextView tv_go_to_pay;//去支付的TextViewprivate TextView tv_intro;//显示线路名称的TextViewprivate TextView tv_num;//显示票数的TextViewprivate TextView tv_reduce;//点击可以票数减1private TextView tv_add;//点击可以票数加1private EditText et_time;//日历EditText,功能测试ingprivate Context context;//Contextprivate String account;//获取从主界面传来的账号private double totalPrice = 0.00;//总价钱private int totalCount = 0;//总票数private String priceString;//单件,String类型的CalendarFragment calendarFragment;//日历的Fragmentint lineID=0;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);//设置无标题requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_reserve);initView();initEvents();}/*** 初始化操作*/public void initView(){context = this;//获取账号account = getIntent().getStringExtra("account");tv_back = (TextView)findViewById(R.id.tv_back);//返回tv_price = (TextView)findViewById(R.id.tv_price);//显示单价的TextViewtv_total_price = (TextView)findViewById(R.id.tv_total_price);//显示总价钱的TextViwtv_clear = (TextView)findViewById(R.id.tv_clear);//点击清空,总价置0tv_go_to_pay = (TextView)findViewById(R.id.tv_go_to_pay);//去付款tv_num = (TextView)findViewById(R.id.tv_num);//显示票数的TextViewtv_reduce = (TextView)findViewById(R.id.tv_reduce);//点击票数减1tv_add = (TextView)findViewById(R.id.tv_add);//点击票数加1et_time = (EditText)findViewById(R.id.et_time);//出游时间String tourism_time = getIntent().getExtras().getString("tourism_time");et_time.setText(tourism_time);double price = getIntent().getExtras().getDouble("price");totalCount=1;totalPrice = price;tv_price.setText("¥"+price);tv_total_price.setText("¥"+price);priceString = tv_price.getText().toString().replace("¥", "");//获取单价tv_num.setText("1");tv_go_to_pay.setText("结算(1)");lineID=getIntent().getExtras().getInt("ID");String name = getIntent().getExtras().getString("name");tv_intro=(TextView)findViewById(R.id.tv_intro);//线路名称tv_intro.setText(name);}/*** 事件操作*/public void initEvents(){tv_back.setOnClickListener(this);tv_clear.setOnClickListener(this);tv_go_to_pay.setOnClickListener(this);tv_reduce.setOnClickListener(this);tv_add.setOnClickListener(this);et_time.setOnClickListener(this);}@Overridepublic void onClick(View v) {AlertDialog alert;switch (v.getId()){case R.id.et_time:break;case R.id.tv_go_to_pay:if (totalCount == 0){Toast.makeText(context, "请选择要预定的旅游服务", Toast.LENGTH_LONG).show();return;}alert = new AlertDialog.Builder(context).create();alert.setTitle("操作提示");alert.setMessage("总计:\n" + totalCount + "张票\n" + totalPrice + "元");alert.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", new DialogInterface.OnClickListener(){@Overridepublic void onClick(DialogInterface dialog, int which){return;}});alert.setButton(DialogInterface.BUTTON_POSITIVE, "确定", new DialogInterface.OnClickListener(){@Overridepublic void onClick(DialogInterface dialog, int which){String countString = String.valueOf(totalCount);//票数String priceString = String.valueOf(totalPrice);//单价String lineIdString = Integer.toString(lineID);//旅游路线IDString timeString = et_time.getText().toString();//出游时间//执行异步任务new AddOrderAsyncTask().execute(Constant.URL_AddOrder,account,countString,priceString,lineIdString,timeString);}});alert.show();break;case R.id.tv_clear:if (totalCount == 0){Toast.makeText(context, "请选择要取消预定的旅游服务", Toast.LENGTH_LONG).show();return;}alert = new AlertDialog.Builder(context).create();alert.setTitle("操作提示");alert.setMessage("您确定要取消预定的旅游服务吗?");alert.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", new DialogInterface.OnClickListener(){@Overridepublic void onClick(DialogInterface dialog, int which){return;}});alert.setButton(DialogInterface.BUTTON_POSITIVE, "确定", new DialogInterface.OnClickListener(){@Overridepublic void onClick(DialogInterface dialog, int which){totalCount = 0;totalPrice = 0.00;tv_num.setText("0");tv_total_price.setText("¥0.00");tv_go_to_pay.setText("结算(0)");}});alert.show();break;case R.id.tv_back:this.finish();break;case R.id.tv_reduce:if(totalCount >= 1){totalCount--;tv_num.setText(String.valueOf(totalCount));totalPrice = Double.parseDouble(priceString)*totalCount;                tv_total_price.setText(String.valueOf(totalPrice));tv_go_to_pay.setText("结算("+totalCount+")");}else if(totalCount <= 0){Toast.makeText(context, "数量不可以小于0哦!", 1).show();}break;case R.id.tv_add:totalCount++;tv_num.setText(String.valueOf(totalCount));totalPrice = Double.parseDouble(priceString)*totalCount;tv_total_price.setText(String.valueOf(totalPrice));tv_go_to_pay.setText("结算("+totalCount+")");break;}}/****简介AsyncTask可以使得使用UI线程变的更容易更适当,它可以在后台运行一些操作然后在UI上展现,不用操作具体的线程和handlers一个 asynchronous task包括三种基本类型(调用参数,进度和结果),和四个步骤(调用开始,在后台运行,处理进度,结束)), and most often will override a second one (onPostExecute(Result).)使用方法描述Asynchronous Task必须是作为一个子类来使用,task实例必须在UI线程创建execute(Params...)必须在UI线程调用不要手工调用onPreExecute(), onPostExecute(Result), doInBackground(Params...), onProgressUpdate(Progress...)。task只可以execute一次,执行多次就报异常**/class AddOrderAsyncTask extends AsyncTask<String, Void, String>{@Overrideprotected String doInBackground(String... params) {AddOrderService addOrderService = new AddOrderService();String retStr = addOrderService.addOrder(params[0], params[1],params[2],params[3],params[4],params[5]);return retStr;}@Overrideprotected void onPostExecute(String result) {// TODO Auto-generated method stubsuper.onPostExecute(result);if(result.equals("error")){Toast.makeText(getApplicationContext(), "提交订单失败!", 1).show();}else if(result.equals("success")){Toast.makeText(getApplicationContext(), "提交订单成功!", 1).show();ReserveActivity.this.finish();}}}}

Android旅游自助项目之订票系统订票功能实现相关推荐

  1. 基于ssh的航空订票系统-飞机订票系统javaweb-机票订购课程设计java代码(源码+数据库文件+文档)

    基于ssh的航空订票系统-飞机订票系统javaweb-机票订购java代码(源码+数据库文件+文档) 注意:该项目只展示部分功能,如需了解,评论区咨询即可. 作者:IT跃迁谷 1.开发环境 开发语言: ...

  2. 航空订票系统--页面及功能介绍

    前面经过数据逻辑层的分析,本文将从页面的效果以及功能实现代码角度讲述,因为时间以及能力问题,有些功能没有来得及实现,部分页面用模拟数据代替...管理员后台主要使用Ext js框架,前台主要为aspx页 ...

  3. android实训项目无线点餐系统服务器的设置,实现Android客户端软件与云计算的无线点餐系统设计...

    移动互联网时代来临,一个崭新的时代开始了! 所谓移动互联网就是将移动通信和互联网整合在一起,是移动设备(包括手机和上网本)可以随时随地访问互联网资源和应用. 云是由许多水分子组成的,几乎有几亿个.云没 ...

  4. Android订票系统订票功能实现(特效点击按钮实现票数自动加减1)

    要实现的效果是点击加按钮就购买分数自动加一,同时计算合计的总计 先共享一份colors.xml的数据,比较全面,可以根据需要添加 <?xml version="1.0" en ...

  5. Android App实战项目之实现手写签名APP功能(附源码,简单易懂 可直接实用)

    运行有问题或需要源码请点赞关注收藏后评论区留言~~~ 一.跟踪滑动轨迹实现手写签名 手写签名的原理是把手机屏幕当作画板,把用户手指当作画笔,手指在屏幕上划来划去,屏幕就会显示手指的移动轨迹,就像画笔在 ...

  6. 12306抢票系统(登录功能---二维码+账号密码)

    文章目录 一.二维码登录方式 二.账号密码登录方式 超级鹰第三方库 账号密码登录 代码汇总: 一.二维码登录方式 二维码登录方式:用户手机端扫描网页二维码登录,比账号密码登录更简易 话不多说,先上代码 ...

  7. C语言版-数据结构-期末课程设计-大作业(航空客运订票系统)附源码+实验文档

    设计题目:航空客运订票系统 本项目涉及到的知识:指针.结构体数组.链表.参数传递 [问题描述]航空客运订票的业务活动包含查询航线和客票预订信息,可以办理订.退票等,用c语言设计一个程序模拟实现. 一. ...

  8. 基于微信小程序电影院选座订票系统 计算机毕设源码26840

    摘  要 随着我国经济迅速发展,人们对手机的需求越来越大,各种手机软件也都在被广泛应用,但是对于手机进行数据信息管理,对于手机的各种软件也是备受用户的喜爱,电影院选座订票系统小程序被用户普遍使用,为方 ...

  9. Loadrunner12录制脚本之飞机订票系统

    这篇文章主要内容是利用Loadrunner软件对其自带的飞机订票系统的登录功能进行录制脚本操作. 准备工作: 工具:win7系统.loadrunner 12.IE浏览器(较新版本).飞机订票系统. 网 ...

最新文章

  1. 美国国防部将把人工智能用于空战
  2. Javascript的原型链、instanceof与typeof
  3. TLSNotary中心化预言机(3) 下一代技术----PADVA
  4. std::make_any
  5. A Software Developer’s Reading Plan
  6. flutter打包出的问题
  7. 20180810 突然发现自己不小心跑到了数据分析呈现岗位
  8. [索尼]笔记本电脑驱动程序安装顺序?
  9. 思维破局:认知水平低,是一个人最致命的短板
  10. 软萌硬核科普必读《大圣陪你学AI》
  11. MySQL生成连续数字
  12. java调用import了第三方库的python脚本为啥就是出不来结果嘞
  13. 计算机神经网络sci,神经网络方向sci期刊
  14. LeetCode(626):换座位 Exchange Seats(SQL)
  15. [转]设置IE背景色保护你的眼睛视力_鹤壁吧_贴吧
  16. 如何运行PHP文件 /创建PHP项目【基于VScode、XAMPP】超级详细,亲测有效,这一篇就够了
  17. TM卡 DS1990A读写程序
  18. php odbc连接池,修复︰ 使用连接池的 SQL Server ODBC 连接时设置的连接属性失败
  19. 网神为互联网+智慧政务保驾护航
  20. 203. 电子编程入门到工程师--逆推原理图(电源部分)

热门文章

  1. python判断两个数据集是否存在包含关系
  2. linux-一条命令,找出包含指定字符串的进程并杀死
  3. c语言 dfs,DFS(深度优先搜索)
  4. Transformer如何用于大规模图像识别?
  5. 2011-1 开篇,要确定好方向
  6. java——财务支票大写汉字转换
  7. SDE:Stochastic Differential Equation 简述
  8. 计算机网络研究进展,计算机网络信息空间(Cyberspace)的人文地理学的研究进展和展望.pdf...
  9. linux远程判断目录是否存在,用shell判断远程主机上是否存在某个文件
  10. 微信的优缺点以及发展史