写出在布局文件中添加控件,如 TextView、Button、ListView 等,用于显示菜品列表、购物车列表、结算金额等信息的代码
时间: 2023-07-04 17:12:02 浏览: 47
好的,以下是一个简单的布局文件,包含了 TextView、Button 和 ListView 控件,用于显示菜品列表、购物车列表、结算金额等信息的代码:
```xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- 菜品列表 -->
<TextView
android:id="@+id/tv_menu_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="菜单列表"
android:textSize="20sp" />
<ListView
android:id="@+id/lv_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- 购物车列表 -->
<TextView
android:id="@+id/tv_cart_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="购物车列表"
android:textSize="20sp" />
<ListView
android:id="@+id/lv_cart"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- 结算信息 -->
<TextView
android:id="@+id/tv_total_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="总价:0元"
android:textSize="20sp" />
<Button
android:id="@+id/btn_checkout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="结算" />
</LinearLayout>
```
以上布局文件中包含了两个 ListView 控件,分别用于显示菜品列表和购物车列表,还有一个 TextView 控件用于显示结算金额,以及一个 Button 控件用于触发结算操作。