我是靠谱客的博主 落后电源,最近开发中收集的这篇文章主要介绍基于Android的手机订餐系统设计与实现(三)基于Android的手机订餐系统设计与实现(三)一、HomeFragmet中的listItem的点击事件。二、ShoppingCarActivity订单提交总结,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述


基于Android的手机订餐系统设计与实现(三)

文章目录

  • 基于Android的手机订餐系统设计与实现(三)
  • 一、HomeFragmet中的listItem的点击事件。
    • 1.gain()
    • 2.建立*CommodityActivity*.java
    • 2.建立*activity_commodity.xml
    • 3.创建TabFragment(重)
    • 4.fragment_tab.xml
    • 4.tab_order.xml
    • 4.tab_comment.xml
    • 4.table_shop.xml
  • 二、ShoppingCarActivity订单提交
    • 1.建立ShoppingCarActivity.java
    • 2.建立activity_shopping_car.xml
    • 2.建立OrderInfoActivity.java
    • 3.建立*activity_order_info*.xml
  • 总结
    • 后续还将继续完成订餐系统的实现


# 前言 提示:上节写到了获取List中的数据,接下来将写道使用RadioGroup控制的滑动页面以及CardView中加载图片文字列表,下篇文章将写,如何构建TabLayout和ViewPager联动,嵌入滑动

以下是本篇文章正文内容,下面案例可供参考

一、HomeFragmet中的listItem的点击事件。

ListItem中点击跳转对应页面,获取目标商品Id从而达到点击跳转。

1.gain()

private String storeid;
	  listItem.setOnItemClickListener((parent, view, position, id) -> {
	  //storeid 为自行定义
                storeid = Objects.requireNonNull(data.get(position).get("id")).toString();
                Intent intent = new Intent(getContext(), CommodityActivity.class);
                intent.putExtra("id",storeid);
                startActivity(intent);
            });

2.建立CommodityActivity.java

//首先定义tabs,还有TabFragmentlist
  	@BindView(R.id.view_pager)
    ViewPager viewPager;
    
 	private String[] tabs = {"点菜", "评价", "商家"};
    private List<TabFragment> tabFragmentList = new ArrayList<>();
     @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_commodity);
        ButterKnife.bind(this);
        initView();
        //判断tab长度,添加
        for (int i = 0; i < tabs.length; i++) {
            tabLayout.addTab(tabLayout.newTab().setText(tabs[i]));
            tabFragmentList.add(TabFragment.newInstance(tabs[i]));
        }
        //viewPager用来加载数据
        viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
            @NonNull
            @Override
            public Fragment getItem(int position) {
                return tabFragmentList.get(position);
            }

            @Override
            public int getCount() {
                return tabFragmentList.size();
            }

            @Nullable
            @Override
            public CharSequence getPageTitle(int position) {
                return tabs[position];
            }

        });

        //设置TabLayout和ViewPager联动
        tabLayout.setupWithViewPager(viewPager, false);
    }
    public static String id;
    private void initView() {
        Intent intent = getIntent();
        id = intent.getStringExtra("id");
        StoreDatabase storeDatabase = new StoreDatabase(this);
        SQLiteDatabase database = storeDatabase.getReadableDatabase();
        List<Map<String, Object>> data = new ArrayList<>();
        @SuppressLint("Recycle") Cursor cursor = database.query("你的数据库名", null, "id=?", new String[]{id}, null, null, null, null);
   
        if (cursor.moveToFirst()) {
            while (!cursor.isAfterLast()) {
               //获取数据存Map
                cursor.moveToNext();
            }
        }
        Log.i("TAG", data.toString());
    }

2.建立*activity_commodity.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".Personage.Activity.CommodityActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:ignore="UselessParent">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:background="@color/white"
            android:orientation="horizontal">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center|left"
                android:background="@mipmap/back"
                tools:ignore="RtlHardcoded" />

            <EditText
                android:id="@+id/edit_inquire"
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:layout_gravity="center"
                android:layout_marginStart="20dp"
                android:background="@drawable/custom_search_background"
                android:focusable="true"
                android:hint="请输入商品名"
                android:paddingStart="5dp"
                android:textColor="@color/black"
                android:textSize="14sp"
                tools:ignore="Autofill,HardcodedText,LabelFor,RtlSymmetry,TextFields" />

            <Button
                android:id="@+id/btn_inquire"
                android:layout_width="75dp"
                android:layout_height="30dp"
                android:layout_gravity="right|center"
                android:background="@drawable/setbar_btn"
                android:clickable="true"
                android:focusable="true"
                android:text="查询"
                android:textColor="@color/white"
                tools:ignore="HardcodedText,RtlHardcoded" />
        </FrameLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/custom_linearlayout_background"
        android:orientation="vertical"
        tools:ignore="UselessParent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                tools:ignore="UselessParent">

                <TextView
                    android:id="@+id/commodit_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="20dp"
                    android:text="华莱士·全鸡汉堡"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:drawableStart="@mipmap/icon_star"
                        tools:ignore="HardcodedText" />

                    <TextView
                        android:id="@+id/show_store_star"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="5.0"
                        android:textColor="@color/chocolate"
                        tools:ignore="HardcodedText" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="月售"
                        android:textColor="@color/gray"
                        tools:ignore="HardcodedText" />

                    <TextView
                        android:id="@+id/show_store_sale"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="2dp"
                        android:text="0"
                        android:textColor="@color/gray"
                        tools:ignore="HardcodedText" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="配送约30分钟"
                        android:textColor="@color/gray"
                        tools:ignore="HardcodedText" />
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="right"
                tools:ignore="RtlHardcoded">

                <ImageView
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:src="@mipmap/dl"
                    android:id="@+id/image"
                    tools:ignore="ContentDescription,RtlHardcoded" />
            </LinearLayout>


        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="2dp"
            android:orientation="horizontal">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="20dp"
                android:text="优惠"
                android:textColor="@color/black"
                android:textSize="18sp"
                tools:ignore="HardcodedText" />
            <TextView
                android:id="@+id/show_store_discount"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="新人下单专享优惠"
                android:layout_marginStart="20dp"
                android:textColor="@color/red"
                tools:ignore="HardcodedText" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="2dp"
            android:orientation="horizontal">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="20dp"
                android:text="商家服务"
                android:textColor="@color/black"
                android:textSize="18sp"
                tools:ignore="HardcodedText" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/show_store_retail"
                android:text="急速退款"
                android:layout_marginStart="20dp"
                android:textColor="@color/black"
                tools:ignore="HardcodedText" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="2dp"
            android:orientation="horizontal">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="20dp"
                android:text="公告"
                android:textColor="@color/black"
                android:textSize="18sp"
                tools:ignore="HardcodedText" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/show_store_notice"
                android:text="测试测试测试"
                android:layout_marginStart="20dp"
                android:textColor="@color/black"
                tools:ignore="HardcodedText" />
        </LinearLayout>
        <com.google.android.material.tabs.TabLayout
            android:layout_width="match_parent"
            android:id="@+id/tab_layout"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:tabTextColor="@color/colorPrimary"
            app:tabSelectedTextColor="@color/colorPrimaryDark"
            android:layout_height="wrap_content">

        </com.google.android.material.tabs.TabLayout>

        <androidx.viewpager.widget.ViewPager
            android:id="@+id/view_pager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toBottomOf="@+id/tab_layout" />
    </LinearLayout>
</LinearLayout>

这个就是xml文件出来的布局

3.创建TabFragment(重)

首先要添加依赖 implements

 public class TabFragment extends Fragment implements LeftMenuAdapter.onItemSelectedListener, ShopCartImp, ShopCartDialog.ShopCartDialogImp {
 //设置各个tab的布局文件
  	@BindView(R.id.shopping_cart_total_tv)
    TextView shoppingCartTotalTv;
    @BindView(R.id.shopping_cart_bottom)
    LinearLayout shoppingCartBottom;
    @BindView(R.id.left_menu)
    RecyclerView leftMenu;
    @BindView(R.id.right_menu)
    RecyclerView rightMenu;
    @BindView(R.id.right_menu_tv)
    TextView rightMenuTv;
    @BindView(R.id.right_menu_item)
    LinearLayout rightMenuItem;
    @BindView(R.id.shopping_cart)
    ImageView shoppingCart;
    @BindView(R.id.shopping_cart_layout)
    FrameLayout shoppingCartLayout;
    @BindView(R.id.shopping_cart_total_num)
    TextView shoppingCartTotalNum;
    @BindView(R.id.relative_order)
    RelativeLayout relativeOrder;
    @BindView(R.id.main_layout)
    RelativeLayout mainLayout;
    @BindView(R.id.shopping_go)
    TextView shoppingGo;
    /**
     * 第二个tab
     */
    @BindView(R.id.star)
    TextView star;
    @BindView(R.id.lin_show)
    LinearLayout linShow;
    @BindView(R.id.list_item)
    ListView listItem;
    @BindView(R.id.swipe_ly)
    SwipeRefreshLayout swipeLy;
    @BindView(R.id.tabComment)
    LinearLayout tabComment;

    /**
     * 第三个tab
     */
    @BindView(R.id.shop_name)
    TextView shopName;
    @BindView(R.id.shop_address)
    TextView shopAddress;
    @BindView(R.id.shop_phone)
    TextView shopPhone;
    @BindView(R.id.shop_type)
    TextView shopType;
    @BindView(R.id.shop_retail)
    TextView shopRetail;
    @BindView(R.id.complaint)
    Button complaint;
    @BindView(R.id.tabShop)
    LinearLayout tabShop;
    
	//添加左右两个容器
    private LeftMenuAdapter leftAdapter;
    private RightDishAdapter rightAdapter;
    private ShopCart shopCart;
    private boolean leftClickType = false;//左侧菜单点击引发的右侧联动
    private DishMenu headMenu;
    private ArrayList<DishMenu> dishMenuList;//数据源
    
   public static TabFragment newInstance(String label) {
    Bundle args = new Bundle();
    args.putString("label", label);
    TabFragment fragment = new TabFragment();
    fragment.setArguments(args);
    return fragment;
   }
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_tab, container, false);
        ButterKnife.bind(this, view);
        id = CommodityActivity.id;
        gain();
        initData();
        initView();
        initAdapter();

        pagetab2();
        tableve2();

        pagetab3();
        tableve3();
        return view;
    }
    //gain就是来获取数据库里的内容添加map后续使用
     private void gain() {
        CommodityDatabase commodityDatabase = new CommodityDatabase(getContext());
        SQLiteDatabase database = commodityDatabase.getReadableDatabase();
        @SuppressLint("Recycle") Cursor cursor = database.query("commodity", null, "id=?", new String[]{id}, null, null, null, null);
        num = cursor.getCount();
        if (cursor.moveToFirst()) {
            while (!cursor.isAfterLast()) {
                Map<String, Object> item = new HashMap<>();
             	//里面做数据添加
                cursor.moveToNext();
                data.add(item);
            }
        }
    }
     private DishMenu menu, menu1, menu2, menu3, menu4, menu5, menu6, menu7, empty;
     //声明菜单,这个菜单是根据数据库所存的菜单进行自动添加
        private void initData() {
        if (num > 0) {
            shopCart = new ShopCart();
            dishMenuList = new ArrayList<>();

            ArrayList<Dish> dishs1 = new ArrayList<>();
            ArrayList<Dish> dishs2 = new ArrayList<>();
            ArrayList<Dish> dishs3 = new ArrayList<>();
            ArrayList<Dish> dishs4 = new ArrayList<>();
            ArrayList<Dish> dishs5 = new ArrayList<>();
            ArrayList<Dish> dishs6 = new ArrayList<>();
            ArrayList<Dish> dishs7 = new ArrayList<>();
            ArrayList<Dish> dishs8 = new ArrayList<>();

            for (int i = 0; i < num; i++) {
                if (Objects.requireNonNull(data.get(i).get("commoditytype")).toString().equals("超值福利")) {
                    dishs1.add(new Dish(Objects.requireNonNull(data.get(i).get("commodityname")).toString(),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commodityprice")).toString()),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commoditynum")).toString())));
                    menu = new DishMenu("超值福利", dishs1);
                } else if (Objects.requireNonNull(data.get(i).get("commoditytype")).toString().equals("爆品推荐")) {
                    dishs2.add(new Dish(Objects.requireNonNull(data.get(i).get("commodityname")).toString(),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commodityprice")).toString()),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commoditynum")).toString())));
                    menu1 = new DishMenu("爆品推荐", dishs2);
                } else if (Objects.requireNonNull(data.get(i).get("commoditytype")).toString().equals("超值折扣")) {
                    dishs3.add(new Dish(Objects.requireNonNull(data.get(i).get("commodityname")).toString(),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commodityprice")).toString()),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commoditynum")).toString())));
                    menu2 = new DishMenu("超值折扣", dishs3);
                } else if (Objects.requireNonNull(data.get(i).get("commoditytype")).toString().equals("单人套餐")) {
                    dishs4.add(new Dish(Objects.requireNonNull(data.get(i).get("commodityname")).toString(),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commodityprice")).toString()),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commoditynum")).toString())));
                    menu3 = new DishMenu("单人套餐", dishs4);
                } else if (Objects.requireNonNull(data.get(i).get("commoditytype")).toString().equals("双人套餐")) {
                    dishs5.add(new Dish(Objects.requireNonNull(data.get(i).get("commodityname")).toString(),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commodityprice")).toString()),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commoditynum")).toString())));
                    menu4 = new DishMenu("双人套餐", dishs5);
                } else if (Objects.requireNonNull(data.get(i).get("commoditytype")).toString().equals("满减小吃")) {
                    dishs6.add(new Dish(Objects.requireNonNull(data.get(i).get("commodityname")).toString(),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commodityprice")).toString()),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commoditynum")).toString())));
                    menu5 = new DishMenu("满减小吃", dishs6);
                } else if (Objects.requireNonNull(data.get(i).get("commoditytype")).toString().equals("折扣")) {
                    dishs7.add(new Dish(Objects.requireNonNull(data.get(i).get("commodityname")).toString(),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commodityprice")).toString()),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commoditynum")).toString())));
                    menu6 = new DishMenu("折扣", dishs7);
                } else if (Objects.requireNonNull(data.get(i).get("commoditytype")).toString().equals("满减饮品")) {
                    dishs8.add(new Dish(Objects.requireNonNull(data.get(i).get("commodityname")).toString(),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commodityprice")).toString()),
                            Integer.parseInt(Objects.requireNonNull(data.get(i).get("commoditynum")).toString())));
                    menu7 = new DishMenu("满减饮品", dishs8);
                }

            }
            if (menu != null) {
                dishMenuList.add(menu);
            }
            if (menu1 != null) {
                dishMenuList.add(menu1);
            }
            if (menu2 != null) {
                dishMenuList.add(menu2);
            }
            if (menu3 != null) {
                dishMenuList.add(menu3);
            }
            if (menu4 != null) {
                dishMenuList.add(menu4);
            }
            if (menu5 != null) {
                dishMenuList.add(menu5);
            }
            if (menu6 != null) {
                dishMenuList.add(menu6);
            }
            if (menu7 != null) {
                dishMenuList.add(menu7);
            }

        } else {
            shopCart = new ShopCart();
            dishMenuList = new ArrayList<>();
            ArrayList<Dish> dishs = new ArrayList<>();
            dishs.add(new Dish("空", 0, 0));
            empty = new DishMenu("空", dishs);
            dishMenuList.add(empty);
        }
    }
    //设置左右两个容器
     private void initView() {

        leftMenu.setLayoutManager(new LinearLayoutManager(getContext()));
        rightMenu.setLayoutManager(new LinearLayoutManager(getContext()));
        rightMenu.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
            }

            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                if (recyclerView.canScrollVertically(1) == false) {//无法下滑
                    showHeadView();
                    return;
                }
                View underView = null;
                if (dy > 0)
                    underView = rightMenu.findChildViewUnder(rightMenuItem.getX(), rightMenuItem.getMeasuredHeight() + 1);
                else
                    underView = rightMenu.findChildViewUnder(rightMenuItem.getX(), 0);
                if (underView != null && underView.getContentDescription() != null) {
                    int position = Integer.parseInt(underView.getContentDescription().toString());
                    DishMenu menu = rightAdapter.getMenuOfMenuByPosition(position);

                    if (leftClickType || !menu.getMenuName().equals(headMenu.getMenuName())) {
                        if (dy > 0 && rightMenuItem.getTranslationY() <= 1 && rightMenuItem.getTranslationY() >= -1 * rightMenuItem.getMeasuredHeight() * 4 / 5 && !leftClickType) {// underView.getTop()>9
                            int dealtY = underView.getTop() - rightMenuItem.getMeasuredHeight();
                            rightMenuItem.setTranslationY(dealtY);
//                            Log.e(TAG, "onScrolled: "+rightMenuItem.getTranslationY()+"   "+rightMenuItem.getBottom()+"  -  "+rightMenuItem.getMeasuredHeight() );
                        } else if (dy < 0 && rightMenuItem.getTranslationY() <= 0 && !leftClickType) {
                            rightMenuTv.setText(menu.getMenuName());
                            int dealtY = underView.getBottom() - rightMenuItem.getMeasuredHeight();
                            rightMenuItem.setTranslationY(dealtY);
//                            Log.e(TAG, "onScrolled: "+rightMenuItem.getTranslationY()+"   "+rightMenuItem.getBottom()+"  -  "+rightMenuItem.getMeasuredHeight() );
                        } else {
                            rightMenuItem.setTranslationY(0);
                            headMenu = menu;
                            rightMenuTv.setText(headMenu.getMenuName());
                            for (int i = 0; i < dishMenuList.size(); i++) {
                                if (dishMenuList.get(i) == headMenu) {
                                    leftAdapter.setSelectedNum(i);
                                    break;
                                }
                            }
                            if (leftClickType) leftClickType = false;
                            Log.e(TAG, "onScrolled: " + menu.getMenuName());
                        }
                    }
                }
            }
        });

        shoppingCartLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showCart(view);
            }
        });
    }
    //初始化Adapter
       private void initAdapter() {
        leftAdapter = new LeftMenuAdapter(getContext(), dishMenuList);
        rightAdapter = new RightDishAdapter(getContext(), dishMenuList, shopCart);
        rightMenu.setAdapter(rightAdapter);
        leftMenu.setAdapter(leftAdapter);
        leftAdapter.addItemSelectedListener(this);
        rightAdapter.setShopCartImp(this);
        initHeadView();
    }
    //加载
      private void initHeadView() {
        headMenu = rightAdapter.getMenuOfMenuByPosition(0);
        rightMenuItem.setContentDescription("0");
        rightMenuTv.setText(headMenu.getMenuName());
    }
    //关闭处理
    @Override
    public void onDestroy() {
        super.onDestroy();
        leftAdapter.removeItemSelectedListener(this);
    }
        private void showHeadView() {
        rightMenuItem.setTranslationY(0);
        View underView = rightMenu.findChildViewUnder(rightMenuTv.getX(), 0);
        if (underView != null && underView.getContentDescription() != null) {
            int position = Integer.parseInt(underView.getContentDescription().toString());
            DishMenu menu = rightAdapter.getMenuOfMenuByPosition(position + 1);
            headMenu = menu;
            rightMenuTv.setText(headMenu.getMenuName());
            for (int i = 0; i < dishMenuList.size(); i++) {
                if (dishMenuList.get(i) == headMenu) {
                    leftAdapter.setSelectedNum(i);
                    break;
                }
            }
        }
    }

    @Override
    public void onLeftItemSelected(int position, DishMenu menu) {
        int sum = 0;
        for (int i = 0; i < position; i++) {
            sum += dishMenuList.get(i).getDishList().size() + 1;
        }
        LinearLayoutManager layoutManager = (LinearLayoutManager) rightMenu.getLayoutManager();
        Objects.requireNonNull(layoutManager).scrollToPositionWithOffset(sum, 0);
        leftClickType = true;
    }

    @Override
    public void add(View view, int position) {
        int[] addLocation = new int[2];
        int[] cartLocation = new int[2];
        int[] recycleLocation = new int[2];
        view.getLocationInWindow(addLocation);
        shoppingCart.getLocationInWindow(cartLocation);
        rightMenu.getLocationInWindow(recycleLocation);

        PointF startP = new PointF();
        PointF endP = new PointF();
        PointF controlP = new PointF();

        startP.x = addLocation[0];
        startP.y = addLocation[1] - recycleLocation[1];
        endP.x = cartLocation[0];
        endP.y = cartLocation[1] - recycleLocation[1];
        controlP.x = endP.x;
        controlP.y = startP.y;

        final FakeAddImageView fakeAddImageView = new FakeAddImageView(getContext());
        mainLayout.addView(fakeAddImageView);
        fakeAddImageView.setImageResource(R.drawable.ic_add_circle_blue_700_36dp);
        fakeAddImageView.getLayoutParams().width = getResources().getDimensionPixelSize(R.dimen.item_dish_circle_size);
        fakeAddImageView.getLayoutParams().height = getResources().getDimensionPixelSize(R.dimen.item_dish_circle_size);
        fakeAddImageView.setVisibility(View.VISIBLE);
        ObjectAnimator addAnimator = ObjectAnimator.ofObject(fakeAddImageView, "mPointF",
                new PointFTypeEvaluator(controlP), startP, endP);
        addAnimator.setInterpolator(new AccelerateInterpolator());
        addAnimator.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animator) {
                fakeAddImageView.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                fakeAddImageView.setVisibility(View.GONE);
                mainLayout.removeView(fakeAddImageView);
            }

            @Override
            public void onAnimationCancel(Animator animator) {

            }

            @Override
            public void onAnimationRepeat(Animator animator) {

            }
        });
        ObjectAnimator scaleAnimatorX = new ObjectAnimator().ofFloat(shoppingCart, "scaleX", 0.6f, 1.0f);
        ObjectAnimator scaleAnimatorY = new ObjectAnimator().ofFloat(shoppingCart, "scaleY", 0.6f, 1.0f);
        scaleAnimatorX.setInterpolator(new AccelerateInterpolator());
        scaleAnimatorY.setInterpolator(new AccelerateInterpolator());
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.play(scaleAnimatorX).with(scaleAnimatorY).after(addAnimator);
        animatorSet.setDuration(800);
        animatorSet.start();

        showTotalPrice();
    }

    @Override
    public void remove(View view, int position) {
        showTotalPrice();
    }

    @SuppressLint("SetTextI18n")
    private void showTotalPrice() {
        if (shopCart != null && shopCart.getShoppingTotalPrice() > 0) {
            shoppingCartTotalTv.setVisibility(View.VISIBLE);
            shoppingGo.setVisibility(View.VISIBLE);
            shoppingCartTotalTv.setText("¥ " + shopCart.getShoppingTotalPrice());

            shoppingCartTotalNum.setVisibility(View.VISIBLE);
            shoppingCartTotalNum.setText("" + shopCart.getShoppingAccount());

        } else {
            shoppingCartTotalTv.setVisibility(View.GONE);
            shoppingGo.setVisibility(View.GONE);
            shoppingCartTotalNum.setVisibility(View.GONE);
        }
    }

    private void showCart(View view) {
        if (shopCart != null && shopCart.getShoppingAccount() > 0) {
            ShopCartDialog dialog = new ShopCartDialog(getContext(), shopCart, R.style.cartdialog);
            Window window = dialog.getWindow();
            dialog.setShopCartDialogImp(this);
            dialog.setCanceledOnTouchOutside(true);
            dialog.setCancelable(true);
            dialog.show();
            WindowManager.LayoutParams params = Objects.requireNonNull(window).getAttributes();
            params.width = WindowManager.LayoutParams.MATCH_PARENT;
            params.height = WindowManager.LayoutParams.WRAP_CONTENT;
            params.gravity = Gravity.BOTTOM;
            params.dimAmount = 0.5f;
            window.setAttributes(params);
        }
    }

    @Override
    public void dialogDismiss() {
        showTotalPrice();
        rightAdapter.notifyDataSetChanged();
    }
    //接下来就可以设置第二个tab
    //跟上面的就一样的了

4.fragment_tab.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".Merchant.Fragment.TabFragment">

    <include layout="@layout/tab_order"
        android:visibility="visible"/>

    <include layout="@layout/tab_comment"
        android:visibility="visible"/>

    <include layout="@layout/tab_shop"
        android:visibility="visible"/>

</RelativeLayout>

4.tab_order.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relative_order"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/shopping_cart_bottom"
        android:layout_width="match_parent"
        android:layout_height="@dimen/shopping_cart_height"
        android:layout_alignParentBottom="true"
        android:background="@color/black"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/shopping_cart_total_tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="@dimen/shopping_cart_total_price_left_magrin"
            android:text="120"
            android:textAlignment="center"
            android:textColor="@color/white"
            android:textSize="@dimen/shopping_cart_total_price_word_size"
            android:textStyle="bold"
            android:visibility="gone"
            tools:ignore="HardcodedText,RtlCompat,RtlHardcoded" />
        <TextView
            android:id="@+id/shopping_go"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginStart="150dp"
            android:layout_marginLeft="@dimen/shopping_cart_total_price_left_magrin"
            android:text="去下单"
            android:visibility="gone"
            android:textAlignment="center"
            android:textColor="@color/white"
            android:textSize="@dimen/shopping_cart_total_price_word_size"
            android:textStyle="bold"
            tools:ignore="HardcodedText,RtlCompat,RtlHardcoded" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/shopping_cart_bottom"
        android:orientation="horizontal">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/left_menu"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@color/gray" />

        <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/right_menu"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@android:color/white" />

            <include layout="@layout/right_menu_item" />
        </RelativeLayout>
    </LinearLayout>

    <FrameLayout
        android:id="@+id/shopping_cart_layout"
        android:layout_width="@dimen/shopping_cart_circle_size"
        android:layout_height="@dimen/shopping_cart_circle_size"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginBottom="@dimen/shopping_cart_bottom_margin"
        android:background="@drawable/circle_blue"
        android:clickable="true"
        tools:ignore="KeyboardInaccessibleWidget,RtlHardcoded">

        <ImageView
            android:id="@+id/shopping_cart"
            android:layout_width="@dimen/shopping_cart_image_height"
            android:layout_height="@dimen/shopping_cart_image_height"
            android:layout_gravity="center"
            android:src="@drawable/ic_shopping_cart_white_24dp"
            tools:ignore="ContentDescription" />
    </FrameLayout>

    <TextView
        android:id="@+id/shopping_cart_total_num"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/shopping_cart_bottom"
        android:layout_alignRight="@id/shopping_cart_layout"
        android:background="@drawable/small_red_circle"
        android:text="1"
        android:textColor="@color/white"
        android:textSize="10sp"
        android:textStyle="bold"
        android:visibility="gone"
        tools:ignore="HardcodedText,RtlHardcoded,SmallSp" />
</RelativeLayout>

4.tab_comment.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/tabComment"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/star"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="5dp"
            android:layout_marginTop="5dp"
            android:text="4.88"
            android:textColor="@color/orangered"
            android:textSize="30sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="高于附近的85.5%的商家" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="5dp"
            android:layout_marginTop="5dp"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="味道"
                tools:ignore="HardcodedText" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="4.98"
                android:textColor="@color/black"
                tools:ignore="HardcodedText" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:layout_marginTop="5dp"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="包装"
                tools:ignore="HardcodedText" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="4.86"
                android:textColor="@color/black"
                tools:ignore="HardcodedText" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:layout_marginTop="5dp"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="配送服务满意率"
                tools:ignore="HardcodedText" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="92%"
                android:textColor="@color/black"
                tools:ignore="HardcodedText" />

        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/lin_show"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/kong"
        android:visibility="gone"
        tools:ignore="Orientation">

    </LinearLayout>

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swipe_ly"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:id="@+id/list_item"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>

4.table_shop.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/tabShop"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:ignore="UselessParent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            tools:ignore="ScrollViewSize,UselessParent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="10dp"
                android:layout_marginBottom="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="vertical"
                tools:ignore="UselessParent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="10dp"
                    android:orientation="horizontal"
                    tools:ignore="UselessParent">

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:orientation="vertical"
                        tools:ignore="UselessParent">

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"

                            tools:ignore="UselessParent">

                            <TextView
                                android:id="@+id/shop_name"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:text="张姐烤肉拌饭"
                                android:textColor="@color/black"
                                android:textSize="16sp"
                                tools:ignore="HardcodedText" />

                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:orientation="horizontal"
                            tools:ignore="UselessParent">

                            <TextView
                                android:id="@+id/shop_address"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:text="河北省石家庄市藁城区"
                                android:textColor="@color/gray"
                                android:textSize="14sp"
                                tools:ignore="HardcodedText" />
                        </LinearLayout>
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:layout_marginTop="4dp"
                        android:orientation="vertical"
                        tools:ignore="UselessParent">

                        <View
                            android:layout_width="1dp"
                            android:layout_height="38dp"
                            android:background="@color/gray" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginTop="2dp"
                        android:orientation="vertical"
                        tools:ignore="UselessParent">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="38dp"
                            android:id="@+id/shop_phone"
                            android:background="@mipmap/phone" />
                    </LinearLayout>

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="10dp"
                    android:layout_marginBottom="10dp"
                    android:orientation="vertical"
                    tools:ignore="UselessParent">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        tools:ignore="UselessParent">

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="商家信息"
                            android:textColor="@color/black"
                            android:textSize="16sp"
                            tools:ignore="HardcodedText" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:layout_marginTop="5dp"
                        tools:ignore="UselessParent">

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="美食类型:"
                            android:textColor="@color/gray"
                            android:textSize="14sp"
                            tools:ignore="HardcodedText" />

                        <TextView
                            android:id="@+id/shop_type"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text=""
                            android:textColor="@color/gray"
                            android:textSize="14sp"
                            tools:ignore="HardcodedText" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:layout_marginTop="5dp"
                        tools:ignore="UselessParent">

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="营业时间:"
                            android:textColor="@color/gray"
                            android:textSize="14sp"
                            tools:ignore="HardcodedText" />

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="09:30:00-21:30:00"
                            android:textColor="@color/gray"
                            android:textSize="14sp"
                            tools:ignore="HardcodedText" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="68dp"
                android:layout_marginStart="10dp"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="10dp"
                android:layout_marginBottom="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="vertical"
                tools:ignore="UselessParent">


                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="10dp"
                    android:layout_marginBottom="10dp"
                    android:orientation="vertical"
                    tools:ignore="UselessParent">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        tools:ignore="UselessParent">

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="商家服务"
                            android:textColor="@color/black"
                            android:textSize="16sp"
                            tools:ignore="HardcodedText" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:orientation="horizontal"
                        tools:ignore="UselessParent">

                        <TextView
                            android:id="@+id/shop_retail"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="sdasdassadasdsadasdsa"
                            android:textColor="@color/gray"
                            android:textSize="14sp"
                            tools:ignore="HardcodedText" />
                    </LinearLayout>

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="10dp"
                android:layout_marginBottom="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:gravity="center">

                <Button
                    android:layout_width="210dp"
                    android:layout_height="wrap_content"
                    android:background="@drawable/setbar_btn"
                    android:text="投诉商家"
                    android:id="@+id/complaint"
                    android:textColor="@color/white"
                    tools:ignore="HardcodedText" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

table_shop的图

二、ShoppingCarActivity订单提交

1.建立ShoppingCarActivity.java

  public class ShoppingCarActivity extends AppCompatActivity {


    @BindView(R.id.back)
    TextView back;
    @BindView(R.id.user_money)
    TextView userMoney;
    @BindView(R.id.user_address)
    TextView userAddress;
    @BindView(R.id.submit)
    Button submit;
    private String userName, money, balance, phone, time;
    private String id;
    private PayWayDialog dialog;
    private String num = "20210322";
    private Bitmap imagebm;
    private byte[] imagedata;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shopping_car);
        ButterKnife.bind(this);
        Intent intent = getIntent();
        money = intent.getStringExtra("money");

        money = Objects.requireNonNull(money).substring(0, money.indexOf("."));
        Log.i("ren", "onCreate: " + money);
        userName = MainActivity.userId;
        id = CommodityActivity.id;
        @SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日  HH:mm:ss");
        Date curDate = new Date(System.currentTimeMillis());
        time = formatter.format(curDate);
        randomCode();
        initView();
        initView1();

    }


    private void initView() {
        userMoney.setText(money);
        UserDatabase userDatabase = new UserDatabase(this);
        SQLiteDatabase database = userDatabase.getReadableDatabase();
        @SuppressLint("Recycle") Cursor cursor = database.query("user", null, "username=?", new String[]{userName}, null, null, null, null);
        if (cursor.moveToFirst()) {
            while (!cursor.isAfterLast()) {
                phone = cursor.getString(6);
                balance = cursor.getString(3);
                userAddress.setText(cursor.getString(4));
                cursor.moveToNext();
            }
        }
        balance = balance.trim();
    }

    private String shopbalance, shopname;

    /**
     * private int id;
     * private String username;//账号    1
     * private String password;//密码    2
     * private String name; //商铺名称     3
     * private String phone;//商铺电话     4
     * private String address;//商铺地址   5
     * private String notice; //商铺公告   6
     * private String retail;  //商铺服务  7
     * private String discount;//商铺优惠  8
     * private byte[] image;   //商铺照片  9
     * private String sale;    //售出多少份 10
     * private String star;    //星星评分    后面进行总和除于评论数  11
     * private String sendmoney;   //起送金额      12
     * private String type;    //美食类型
     * private String balance; //账户余额
     */

    private void initView1() {
        StoreDatabase storeDatabase = new StoreDatabase(this);
        SQLiteDatabase sqLiteDatabase = storeDatabase.getReadableDatabase();


        @SuppressLint("Recycle") Cursor cursor = sqLiteDatabase.query("store", null, "id=?", new String[]{id}, null, null, null, null);
        if (cursor.moveToFirst()) {
            while (!cursor.isAfterLast()) {
                imagedata = cursor.getBlob(9);
                imagebm = BitmapFactory.decodeByteArray(imagedata, 0, imagedata.length);
                shopname = cursor.getString(3);
                shopbalance = cursor.getString(14);

                cursor.moveToNext();
            }
        }
    }

    @OnClick({R.id.back, R.id.submit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.submit:
            //dialog弹出进行一个余额的对比
                dialog = new PayWayDialog(this, R.style.recharge_pay_dialog, true, v -> {
                    if (PayWayDialog.payWay == 0) {
                        if ((Integer.parseInt(balance) - Integer.parseInt(money)) > 0) {

                            Toast.makeText(this, "支付成功", Toast.LENGTH_SHORT).show();
                            dialog.dismiss();
                            updata();
                        } else {
                            Toast.makeText(this, "支付失败,请充值", Toast.LENGTH_SHORT).show();
                        }
                    } else {
                        Toast.makeText(this, "暂未开通", Toast.LENGTH_SHORT).show();
                    }
                });
                dialog.show();
                dialog.setRechargeNum(money);
                dialog.setDialogBalance(balance);
                break;
        }
    }

    private void updata() {
        UserDatabase userDatabase = new UserDatabase(this);
        SQLiteDatabase sqLiteDatabase = userDatabase.getWritableDatabase();
        ContentValues values = new ContentValues();
        values.put("balance", String.valueOf(Integer.parseInt(balance) - Integer.parseInt(money)));
        sqLiteDatabase.update("user", values, "username=?", new String[]{userName});
        sqLiteDatabase.close();
        updata1();
    }


    private void updata1() {
        StoreDatabase storeDatabase = new StoreDatabase(this);
        SQLiteDatabase sqLiteDatabase = storeDatabase.getWritableDatabase();
        ContentValues values = new ContentValues();
        values.put("balance", String.valueOf(Integer.parseInt(shopbalance) + Integer.parseInt(money)));
        sqLiteDatabase.update("store", values, "id=?", new String[]{id});
        sqLiteDatabase.close();
        updata2();
    }
    //添加到订单
	//这是我所声明的数据库内容
    /**
     * private int id;
     * private String place;//下单人
     * private String money;//下单金额
     * private String type;    //订单状态类型
     * private String shopname; //商铺名字
     * private String address; //配送地址
     * private String time;    //下单时间
     * private String paytype; //支付方式
     * private String phone;   //下单人电话
     * private String num;     //订单号码
     * private byte[] image;   //商铺照片
     */
    private String strRand;

    private void randomCode() {

        for (int i = 0; i < 4; i++) {
            strRand += String.valueOf((int) (Math.random() * 10));
        }

        strRand = strRand.substring(4,8);
        Log.i("ren", "randomCode: " + strRand);
    }

    private void updata2() {
        Order order = new Order();
        OrderService orderService = new OrderService(this);
        order.setPlace(userName);
        order.setMoney(money);
        order.setType("等待商家接单");
        order.setShopname(shopname);
        order.setAddress(userAddress.getText().toString().trim());
        order.setTime(time);
        order.setPaytype("在线支付");
        order.setPhone(phone);
        order.setNum(num + strRand);
        order.setImage(imagedata);
        orderService.add(order);
        Intent intent = new Intent(this, OrderInfoActivity.class);
        intent.putExtra("num", num + strRand);

        startActivity(intent);
    }
}

2.建立activity_shopping_car.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@mipmap/bj"
    android:orientation="vertical"
    tools:context=".Personage.Activity.ShoppingCarActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        tools:ignore="UselessParent">

        <TextView
            android:id="@+id/back"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="5dp"
            android:drawableLeft="@mipmap/back"
            android:gravity="center"
            android:text="提交订单"
            android:textColor="@color/black"
            android:textSize="20sp"
            tools:ignore="HardcodedText,RtlHardcoded" />
    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="vertical"
                tools:ignore="UselessParent">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:gravity="left"
                    android:text="外卖配送"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />


            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="horizontal"
                tools:ignore="UselessParent">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:gravity="left"
                    android:text="优惠规则:"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />

                <TextView
                    android:id="@+id/user_money"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="20dp"
                    android:gravity="right"
                    android:text="2.94"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="horizontal"
                tools:ignore="UselessParent">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:gravity="left"
                    android:text="收货地址:"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />

                <TextView
                    android:id="@+id/user_address"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:text="------"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />
            </LinearLayout>


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="horizontal"
                tools:ignore="UselessParent">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:gravity="left"
                    android:text="立即送出:"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="20dp"
                    android:gravity="right"
                    android:text="大约30分钟后送达"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="horizontal"
                tools:ignore="UselessParent">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:gravity="left"
                    android:text="号码保护:"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="20dp"
                    android:gravity="right"
                    android:text="当前已开启号码保护"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />
            </LinearLayout>

        </LinearLayout>
    </ScrollView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@drawable/custom_linearlayout_background">

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="提交订单"
            android:id="@+id/submit"
            android:background="@drawable/setbar_btn"
            tools:ignore="HardcodedText" />
    </LinearLayout>

</FrameLayout>

2.建立OrderInfoActivity.java

public class OrderInfoActivity extends AppCompatActivity {

    @BindView(R.id.back)
    TextView back;
    @BindView(R.id.order_state)
    TextView orderState;
    @BindView(R.id.order_name)
    TextView orderName;
    @BindView(R.id.order_money)
    TextView orderMoney;
    @BindView(R.id.order_address)
    TextView orderAddress;
    @BindView(R.id.order_num)
    TextView orderNum;
    @BindView(R.id.order_type)
    TextView orderType;
    @BindView(R.id.order_phone)
    TextView orderPhone;
    @BindView(R.id.order_time)
    TextView orderTime;
    @BindView(R.id.order_image)
    ImageView orderImage;
    @BindView(R.id.order_count)
    TextView orderCount;
    @BindView(R.id.order_place)
    TextView orderPlace;
    @BindView(R.id.text_s)
    TextView textS;
    @BindView(R.id.order_cancel)
    TextView orderCancel;
    @BindView(R.id.text_go)
    TextView textGo;
    @BindView(R.id.text_complaint)
    TextView textComplaint;
    private String num, nums;
    private boolean run = false;
    private final Handler handler = new Handler();
    private boolean run1 = false;
    private final Handler handler1 = new Handler();
    private CountDownTimer timer, timer1, timer2, timer3;
    private String balance, money;
    private String userId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_info);
        ButterKnife.bind(this);
        userId = MainActivity.userId;
        Intent intent = getIntent();
        num = intent.getStringExtra("num");
        gain1();
        nums = num;
        initView();
        initData();
        CONFIg();
        run = true;
        run1 = true;
        handler.postDelayed(task, 1000);
        orderCancel.setVisibility(View.GONE);
    }



    private void gain1() {
        UserDatabase userDatabase = new UserDatabase(this);
        SQLiteDatabase database = userDatabase.getReadableDatabase();
        @SuppressLint("Recycle") Cursor cursor = database.query("user", null, "username=?", new String[]{userId}, null, null, null, null);
        if (cursor.moveToFirst()) {
            while (!cursor.isAfterLast()) {
                balance = cursor.getString(3);
                cursor.moveToNext();
            }
        }
        balance = balance.trim();
    }


    //1s刷新一次页面
    private final Runnable task = new Runnable() {
        @Override
        public void run() {
            if (run) {
                gain();
                initData();
                CONFIg();
                handler.postDelayed(this, 1000);

            }
        }
    };

    private void gain() {
        OrderDatabase orderDatabase = new OrderDatabase(this);
        SQLiteDatabase database = orderDatabase.getReadableDatabase();
        @SuppressLint("Recycle") Cursor cursor = database.query("orders", null, "num=?", new String[]{nums}, null, null, null, null);
        if (cursor.moveToFirst()) {
            while (!cursor.isAfterLast()) {
                orderState.setText(cursor.getString(3));
                cursor.moveToNext();
            }
        }
    }

    /**
     * private int id;
     * private String place;//下单人   1
     * private String money;//下单金额2
     * private String type;    //订单状态类型3
     * private String shopname; //商铺名字4
     * private String address; //配送地址5
     * private String time;    //下单时间6
     * private String paytype; //支付方式7
     * private String phone;   //下单人电话8
     * private String num;     //订单号码9
     * private byte[] image;   //商铺照片10
     */
    private void initView() {
        OrderDatabase orderDatabase = new OrderDatabase(this);
        SQLiteDatabase database = orderDatabase.getReadableDatabase();
        @SuppressLint("Recycle") Cursor cursor = database.query("orders", null, "num=?", new String[]{nums}, null, null, null, null);
        byte[] imagedata;
        Bitmap imagebm;
        if (cursor.moveToFirst()) {
            while (!cursor.isAfterLast()) {
                imagedata = cursor.getBlob(10);
                imagebm = BitmapFactory.decodeByteArray(imagedata, 0, imagedata.length);
                orderPlace.setText(cursor.getString(1));
                orderMoney.setText(cursor.getString(2));
                money = cursor.getString(2);
                orderState.setText(cursor.getString(3));
                orderName.setText(cursor.getString(4));
                orderAddress.setText(cursor.getString(5));
                orderTime.setText(cursor.getString(6));
                orderType.setText(cursor.getString(7));
                orderPhone.setText(cursor.getString(8));
                orderNum.setText(cursor.getString(9));
                orderImage.setImageBitmap(imagebm);
                cursor.moveToNext();
            }
        }
    }

    private void initData() {
        if (orderState.getText().toString().equals("等待商家接单")) {
            orderCancel.setVisibility(View.VISIBLE);
            Log.i("ren", "第一次: ");
            timer = new CountDownTimer(15000 + 200, 1000) {
                @SuppressLint("SetTextI18n")
                @Override
                public void onTick(long millisUntilFinished) {
                    orderCount.setText("商家剩余接单时间(" + millisUntilFinished / 1000 + ")");
                }

                @Override
                public void onFinish() {
                    orderCancel.setVisibility(View.GONE);
                    confing(0);
                    timer.cancel();
                }
            }.start();
        }
    }


    private void confing(int i) {
        if (i == 0) {
            OrderDatabase orderDatabase = new OrderDatabase(this);
            SQLiteDatabase sqLiteDatabase = orderDatabase.getWritableDatabase();
            ContentValues values = new ContentValues();
            values.put("type", "商家正在备货");
            sqLiteDatabase.update("orders", values, "num=?", new String[]{nums});
            sqLiteDatabase.close();
            timer.cancel();
            initData();
        }
    }
    private void CONFIg() {
        if (!orderState.getText().toString().equals("等待商家接单")){
            orderCancel.setVisibility(View.GONE);
            orderCount.setVisibility(View.GONE);
            textS.setVisibility(View.GONE);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (timer != null) {
            timer.cancel();
        } 
    }

    @OnClick({R.id.back, R.id.order_cancel, R.id.text_go,R.id.text_complaint})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.order_cancel:
                OrderDatabase orderDatabase = new OrderDatabase(this);
                SQLiteDatabase sqLiteDatabase = orderDatabase.getWritableDatabase();
                ContentValues values = new ContentValues();
                values.put("type", "已取消");
                values.put("balance", (Integer.parseInt(balance) + Integer.parseInt(money)));
                sqLiteDatabase.update("orders", values, "num=?", new String[]{nums});
                sqLiteDatabase.close();
                finish();
                break;
            case R.id.text_go:
                if ((orderState.getText().toString().equals("待评价")) || (orderState.getText().toString().equals("已评价"))) {
                    Intent intent = new Intent(this, EvaluateActivity.class);
                    intent.putExtra("num", nums);
                    intent.putExtra("type",orderState.getText().toString());
                    startActivity(intent);
                } else {
                    Toast.makeText(this, "订单还未完成,请等待", Toast.LENGTH_SHORT).show();
                }
                break;
            case R.id.text_complaint:
                Intent intent = new Intent(this, ComplaintActivity.class);
                intent.putExtra("num", nums);
                startActivity(intent);
                break;
        }
    }
}

3.建立activity_order_info.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@mipmap/bj"
    android:orientation="vertical"
    tools:context=".Personage.Activity.OrderInfoActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        tools:ignore="UselessParent">

        <TextView
            android:id="@+id/back"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="5dp"
            android:drawableLeft="@mipmap/back"
            android:gravity="center"
            android:text="查看订单"
            android:textColor="@color/black"
            android:textSize="20sp"
            tools:ignore="HardcodedText,RtlHardcoded" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:background="@drawable/custom_linearlayout_background"
        android:orientation="horizontal"
        tools:ignore="UselessParent">

        <TextView
            android:id="@+id/order_cancel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:gravity="center"
            android:text="取消订单"
            android:textColor="@color/black"
            android:textSize="18sp"
            android:visibility="gone"
            tools:ignore="HardcodedText,RtlHardcoded" />

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="horizontal"
                tools:ignore="UselessParent">

                <TextView
                    android:id="@+id/order_state"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:gravity="left"
                    android:text="订单状态"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />

                <TextView
                    android:id="@+id/order_count"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:gravity="left"
                    android:text="300"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />

                <TextView
                    android:id="@+id/text_s"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:gravity="left"
                    android:text="s"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />
            </LinearLayout>


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="vertical"
                tools:ignore="UselessParent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="2dp"
                        android:gravity="center"
                        android:text="感谢您对订餐啦的信任,期待您的再次光临"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginStart="20dp"
                        android:layout_marginEnd="20dp"
                        android:background="@color/black" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"

                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="50dp"
                        android:layout_gravity="center"
                        android:layout_marginStart="20dp"
                        android:layout_marginEnd="20dp"
                        android:layout_weight="1"
                        android:drawableTop="@mipmap/lxkf"
                        android:drawablePadding="10dp"
                        android:gravity="center"
                        android:text="联系客服"
                        tools:ignore="HardcodedText" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="50dp"
                        android:layout_gravity="center"
                        android:layout_marginStart="20dp"
                        android:layout_marginEnd="20dp"
                        android:layout_weight="1"
                        android:drawableTop="@mipmap/sqsh"
                        android:drawablePadding="10dp"
                        android:gravity="center"
                        android:text="申请售后"
                        tools:ignore="HardcodedText" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="50dp"
                        android:layout_marginStart="20dp"
                        android:layout_marginEnd="20dp"
                        android:layout_weight="1"
                        android:drawableTop="@mipmap/dashang"
                        android:drawablePadding="10dp"
                        android:gravity="center"
                        android:text="打赏骑士"
                        tools:ignore="HardcodedText" />
                </LinearLayout>
            </LinearLayout>


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="vertical"
                tools:ignore="UselessParent">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:drawableStart="@mipmap/duigou"
                    android:gravity="center"
                    android:text="食物无忧理赔申请"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="30dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="10dp"
                    android:gravity="center"
                    android:text="如发现食物变质、存在异物或引发就医,均可申请理赔"
                    android:textColor="@color/gray"
                    android:textSize="14sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="vertical"
                tools:ignore="UselessParent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <ImageView
                        android:id="@+id/order_image"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:id="@+id/order_name"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="left"
                        android:text="商家名称:"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/custom_linearlayout_background"
                    android:gravity="right"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"

                        android:layout_marginEnd="10dp"
                        android:text="实付金额"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:id="@+id/order_money"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginEnd="20dp"
                        android:gravity="right"
                        android:text="2.94"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="horizontal"
                tools:ignore="UselessParent">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="10dp"
                    android:id="@+id/text_complaint"
                    android:layout_marginBottom="10dp"
                    android:drawableEnd="@mipmap/you"
                    android:text="我要投诉"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="horizontal"
                tools:ignore="UselessParent">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_marginEnd="10dp"
                    android:id="@+id/text_go"
                    android:layout_marginBottom="10dp"
                    android:drawableEnd="@mipmap/you"
                    android:text="我的评价"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    tools:ignore="HardcodedText,RtlHardcoded" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="vertical"
                tools:ignore="UselessParent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="left"
                        android:text="配送信息"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:text="送达时间"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="right"
                        android:text="尽快送达"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:text="收货地址"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:id="@+id/order_address"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="120dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="right"
                        android:text="水水水水水水水水水水水水水水水水水水水"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:text="配送方式"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="120dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="right"
                        android:text="骑手专送"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="40dp"
                android:background="@drawable/custom_linearlayout_background"
                android:orientation="vertical"
                tools:ignore="UselessParent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="left"
                        android:text="订单信息"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:text="订单号"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:id="@+id/order_num"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="right"
                        android:text="202103220000"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:text="下单人姓名"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:id="@+id/order_place"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="right"
                        android:text="liuxx"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:text="支付方式"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:id="@+id/order_type"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="right"
                        android:text="在线支付"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:text="订单电话"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:id="@+id/order_phone"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="right"
                        android:text="15502569547"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:text="下单时间"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:id="@+id/order_time"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="right"
                        android:text="2020-12-31  12:30:30"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/custom_linearlayout_background"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:text="备注"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="120dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="10dp"
                        android:gravity="right"
                        android:text="无"
                        android:textColor="@color/black"
                        android:textSize="18sp"
                        tools:ignore="HardcodedText,RtlHardcoded" />
                </LinearLayout>
            </LinearLayout>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:gravity="center"
                android:text="已经到底了"
                tools:ignore="HardcodedText" />
        </LinearLayout>
    </ScrollView>
</LinearLayout>

在这里插入图片描述

总结

这里对文章第二部分的总结:
以上就是今天要讲的内容,本文仅仅介绍了如何使用TabLayout和ViewPager联动,嵌入滑动,和模拟支付的功能,后续将写道查看我的订单,订单完成后的评价,和投诉该订单。

后续还将继续完成订餐系统的实现

基于Android的手机订餐系统设计与实现(一)
基于Android的手机订餐系统设计与实现(二)

最后

以上就是落后电源为你收集整理的基于Android的手机订餐系统设计与实现(三)基于Android的手机订餐系统设计与实现(三)一、HomeFragmet中的listItem的点击事件。二、ShoppingCarActivity订单提交总结的全部内容,希望文章能够帮你解决基于Android的手机订餐系统设计与实现(三)基于Android的手机订餐系统设计与实现(三)一、HomeFragmet中的listItem的点击事件。二、ShoppingCarActivity订单提交总结所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部