云快卖,提供专业好用的外卖系统、跑腿系统和同城信息系统,公众号+小程序+APP多端适用。
指定菜单项显示的文字,就是这么简单
2023-12-11 15:01:34 云快卖

首页的设计很简单小程序订餐平台,最内层是强化版,只包含一个下拉刷新布局,之后嵌套一个滚动控件,大功告成。代码如下:


<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
androidx.coordinatorlayout.widget.CoordinatorLayout>

java文件或许就是展示列表:1、创建数据源2、创建适配器,同时加载数据源3、设置适配器。

之后给下拉刷新布局设置个窃听器,之后通知适配器更新数据源。

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, container, false);
        // 创建数据源
        initFoods();
        RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(),2);
        recyclerView.setLayoutManager(gridLayoutManager);
        // 创建适配器,同时加载数据源
        foodAdapter = new FoodAdapter(foodList);
        // 设置适配器
        recyclerView.setAdapter(foodAdapter);
        swipeRefresh = view.findViewById(R.id.swipe_refresh);
        swipeRefresh.setColorSchemeResources(R.color.design_default_color_primary);
        swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                refreshFoods();
            }
        });
        return view;
    }

4.4购物车

购物车的也十分简单,须要注意每位布局/控件的和属性。

最内层,真的太好用了,强烈推荐!和首页布局惟一不同的就是上面还包了一个漂浮按键。


<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_marginBottom="80dp"
        android:layout_marginRight="30dp"
        android:src="@mipmap/nav_task"
        app:maxImageSize="50dp"
        android:backgroundTint="@color/Azure"
        android:elevation="8dp"/>
    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
androidx.coordinatorlayout.widget.CoordinatorLayout>

java文件或许就是获取控件实例,之后设置窃听器,这儿我们就展示漂浮按键的窃听器吧,备考下的标准用法,作为模板。

程序平台订餐小程序是啥_订餐小程序制作多少钱_小程序订餐平台

 // 订单提交
 fab.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
          AlertDialog alertDialog = new AlertDialog.Builder(view.getContext())
                  .setTitle("提示")
                  .setIcon(R.drawable.ic_order)
                  .setMessage("您确定要提交订单吗?")
                  .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialogInterface, int i) {
                          cartDao.openDB();
                          cartDao.commitOrder();
                          cartDao.clearCart();
                          cartDao.closeDB();
                          Toast.makeText(getContext(), "下单成功!请下拉刷新页面~", Toast.LENGTH_SHORT).show();
                      }
                  })
                  .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialogInterface, int i) {
                          Toast.makeText(getContext(), "订单已取消", Toast.LENGTH_SHORT).show();
                      }
                  })
                  .show();
            }
    });

4.5我的

布局就很中规中矩了,最常见的布局和控件,不再赘言了,只要花时间都能设计好的布局。

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/Azure"
        android:orientation="vertical">
        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/circle_image"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="20dp"
            app:civ_border_width="2dp"
            android:src="@mipmap/nav_icon"
            app:civ_border_color="@color/CadetBlue"
            android:layout_marginBottom="20dp"/>
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:background="@drawable/ic_chihuo"/>
        <View
            style="@style/PersonLineStyle"
            android:layout_marginTop="10dp"
            android:background="@color/white"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/LightCyan">
            <ImageView
                style="@style/PersonImageStyle"
                android:src="@drawable/ic_person"/>
            <TextView
                android:id="@+id/person"
                style="@style/PersonTvStyle"
                android:text="@string/person" />
        LinearLayout>
        <View
            style="@style/PersonLineStyle"
            android:background="@color/white"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/LightCyan">
            <ImageView
                style="@style/PersonImageStyle"
                android:src="@drawable/ic_order"/>
            <TextView
                android:id="@+id/order"
                style="@style/PersonTvStyle"
                android:text="@string/order" />
        LinearLayout>
        <View
            style="@style/PersonLineStyle"
            android:background="@color/white"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/LightCyan">
            <ImageView
                style="@style/PersonImageStyle"
                android:src="@drawable/ic_share"/>
            <TextView
                android:id="@+id/share"
                style="@style/PersonTvStyle"
                android:text="@string/share" />
        LinearLayout>
        <View
            style="@style/PersonLineStyle"
            android:background="@color/white"/>
        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:cardCornerRadius="6dp"
            android:elevation="5dp">
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_more"/>
        androidx.cardview.widget.CardView>
    LinearLayout>

java代码就是获取控件实例,之后绑定窃听器,最后展示下滑动菜单栏选中风波的窃听器,也就是关掉侧滑菜单。

  // 菜单项选中事件的监听器
  navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
      @Override
      public boolean onNavigationItemSelected(MenuItem item) {
          drawerLayout.closeDrawers();
          return true;
      }
  });

4.6滑动菜单

是中提供的一个控件,致使滑动菜单界面的实现显得十分简单。使用之前,还须要打算两个东西:menu和,menu是拿来在中显示具体菜单项的,则是拿来在中显示颈部布局的。

res/menu/.xml就是具体的菜单项,

标签中嵌套一个标签小程序订餐平台,group表示一个组,指定为表示组中所有菜单项只能单选。之后定义五个,使用id属性指定菜单项的id,icon指定菜单项的图标,title指定菜单项显示的文字,就是如此简单。

程序平台订餐小程序是啥_订餐小程序制作多少钱_小程序订餐平台

/中就是脸部布局,我们这儿简单起见,只放置了头像、用户名和邮箱地址这三项内容,这儿就用到了对头像进行矩形化。

五、运行演示

用AS打开项目,进行建立,Build成功后,打开AVD运行项目,由于本项目包含动漫疗效,所以通过视频展示疗效最佳。

实现订餐系统

六、项目总结

本次订餐系统,不同于往年任何项目,历史性地使用了来设计UI,图标多达三十个,颜色使用了数十种,中定义了系统的主题,中定义了基础控件的属性。有九个功能页面,每一处点击都与数据库进行交互,可以说代码的强壮性早已经过多次测试,很鲁棒。每一处细节也尽量做到位,历时25h塑造。希望你们能从小学到的UI设计的风格。

七、源码获取♻️下边两种形式都可以获取源代码

1️⃣点击直接下载订餐系统

免责声明:部分文章信息来源于网络以及网友投稿,本站只负责对文章进行整理、排版、编辑,出于传递更多信息之目的,并不意味着赞同其观点或证实其内容的真实性,如本站文章和转稿涉及版权等问题,请作者在及时联系本站,我们会尽快为您处理。

云快卖

留言咨询

×