欧美午夜精品久久久久免费视/欧美黄色精品/国产一级A片在线播出/A片免费视频在线观看

指定菜單項(xiàng)顯示的文字,就是這么簡(jiǎn)單
2023-12-11 15:01:34 歡樂點(diǎn)

首頁(yè)的設(shè)計(jì)很簡(jiǎn)單小程序訂餐平臺(tái),最內(nèi)層是強(qiáng)化版,只包含一個(gè)下拉刷新布局,之后嵌套一個(gè)滾動(dòng)控件,大功告成。代碼如下:


<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、創(chuàng)建數(shù)據(jù)源2、創(chuàng)建適配器,同時(shí)加載數(shù)據(jù)源3、設(shè)置適配器。

之后給下拉刷新布局設(shè)置個(gè)竊聽器,之后通知適配器更新數(shù)據(jù)源。

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, container, false);
        // 創(chuàng)建數(shù)據(jù)源
        initFoods();
        RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(),2);
        recyclerView.setLayoutManager(gridLayoutManager);
        // 創(chuàng)建適配器,同時(shí)加載數(shù)據(jù)源
        foodAdapter = new FoodAdapter(foodList);
        // 設(shè)置適配器
        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購(gòu)物車

購(gòu)物車的也十分簡(jiǎn)單,須要注意每位布局/控件的和屬性。

最內(nèi)層,真的太好用了,強(qiáng)烈推薦!和首頁(yè)布局惟一不同的就是上面還包了一個(gè)漂浮按鍵。


<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文件或許就是獲取控件實(shí)例,之后設(shè)置竊聽器,這兒我們就展示漂浮按鍵的竊聽器吧,備考下的標(biāo)準(zhǔn)用法,作為模板。

 // 訂單提交
 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(), "下單成功!請(qǐng)下拉刷新頁(yè)面~", 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我的

布局就很中規(guī)中矩了,最常見的布局和控件,不再贅言了,只要花時(shí)間都能設(shè)計(jì)好的布局。

<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代碼就是獲取控件實(shí)例,之后綁定竊聽器,最后展示下滑動(dòng)菜單欄選中風(fēng)波的竊聽器,也就是關(guān)掉側(cè)滑菜單。

  // 菜單項(xiàng)選中事件的監(jiān)聽器
  navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
      @Override
      public boolean onNavigationItemSelected(MenuItem item) {
          drawerLayout.closeDrawers();
          return true;
      }
  });

4.6滑動(dòng)菜單

是中提供的一個(gè)控件,致使滑動(dòng)菜單界面的實(shí)現(xiàn)顯得十分簡(jiǎn)單。使用之前,還須要打算兩個(gè)東西:menu和,menu是拿來(lái)在中顯示具體菜單項(xiàng)的,則是拿來(lái)在中顯示頸部布局的。

res/menu/.xml就是具體的菜單項(xiàng),

標(biāo)簽中嵌套一個(gè)標(biāo)簽小程序訂餐平臺(tái),group表示一個(gè)組,指定為表示組中所有菜單項(xiàng)只能單選。之后定義五個(gè),使用id屬性指定菜單項(xiàng)的id,icon指定菜單項(xiàng)的圖標(biāo),title指定菜單項(xiàng)顯示的文字,就是如此簡(jiǎn)單。

/中就是臉部布局,我們這兒簡(jiǎn)單起見,只放置了頭像、用戶名和郵箱地址這三項(xiàng)內(nèi)容,這兒就用到了對(duì)頭像進(jìn)行矩形化。

五、運(yùn)行演示

用AS打開項(xiàng)目,進(jìn)行建立,Build成功后,打開AVD運(yùn)行項(xiàng)目,由于本項(xiàng)目包含動(dòng)漫療效,所以通過(guò)視頻展示療效最佳。

實(shí)現(xiàn)訂餐系統(tǒng)

六、項(xiàng)目總結(jié)

本次訂餐系統(tǒng),不同于往年任何項(xiàng)目,歷史性地使用了來(lái)設(shè)計(jì)UI,圖標(biāo)多達(dá)三十個(gè),顏色使用了數(shù)十種,中定義了系統(tǒng)的主題,中定義了基礎(chǔ)控件的屬性。有九個(gè)功能頁(yè)面,每一處點(diǎn)擊都與數(shù)據(jù)庫(kù)進(jìn)行交互,可以說(shuō)代碼的強(qiáng)壯性早已經(jīng)過(guò)多次測(cè)試,很魯棒。每一處細(xì)節(jié)也盡量做到位,歷時(shí)25h塑造。希望你們能從小學(xué)到的UI設(shè)計(jì)的風(fēng)格。

七、源碼獲取??下邊兩種形式都可以獲取源代碼

1??點(diǎn)擊直接下載訂餐系統(tǒng)

免責(zé)聲明:部分文章信息來(lái)源于網(wǎng)絡(luò)以及網(wǎng)友投稿,本站只負(fù)責(zé)對(duì)文章進(jìn)行整理、排版、編輯,出于傳遞更多信息之目的,并不意味著贊同其觀點(diǎn)或證實(shí)其內(nèi)容的真實(shí)性,如本站文章和轉(zhuǎn)稿涉及版權(quán)等問題,請(qǐng)作者在及時(shí)聯(lián)系本站,我們會(huì)盡快為您處理。

歡樂點(diǎn)

留言咨詢

×