本界面主要功能:

显示菜品的详细信息及对该菜品的评论

Acitivity:DetailsPage

package com.example.fanpeng.smartcanteen;import android.content.Intent;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;import org.litepal.LitePal;import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;public class DetailsPage extends AppCompatActivity {private TextView dishName,dishPrice,dishGrade;private Button btn,btn_f5;private ImageView dishImage;private List<Comment> commentList;private String TAG="MyCheck";@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_details_page);Intent intent=getIntent();Bundle bundle=intent.getExtras();Dishes dishes=(Dishes)bundle.getSerializable("dishes");User user=(User)bundle.getSerializable("user");Log.d(TAG,dishes.getName());dishName=findViewById(R.id.show_dish_name);dishPrice=findViewById(R.id.show_dish_price);dishGrade=findViewById(R.id.show_dish_grade);dishImage=findViewById(R.id.show_dish_image);btn=findViewById(R.id.add_comment);btn_f5=findViewById(R.id.f5_comment);//dishImage//dishImage.set//图片暂时未设置dishName.setText(dishes.getName());dishPrice.setText(String.valueOf(dishes.getPrice())+"元");double AverGrade= LitePal.where("dishes_id = ?",String.valueOf(dishes.getId())).average(Comment.class,"grade");BigDecimal b=new BigDecimal(AverGrade);AverGrade=b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();dishGrade.setText("评分:"+String.valueOf(AverGrade));dishImage.setImageBitmap(BitmapFactory.decodeFile(dishes.getPicturePath()));//评论列表///commentList= LitePal.where("dishes_id=?",String.valueOf(dishes.getId())).find(Comment.class);//初始化CommentAdapter adapter=new CommentAdapter(DetailsPage.this,R.layout.comment_menu,commentList);ListView listView=findViewById(R.id.comment_list);listView.setAdapter(adapter);//添加评论/btn.setOnClickListener(new addListener(user,dishes));btn_f5.setOnClickListener(new f5Listener(dishes));}public class f5Listener implements  View.OnClickListener{Dishes dishes;public f5Listener(Dishes dishes){this.dishes=dishes;}@Overridepublic void onClick(View v) {commentList= LitePal.where("dishes_id=?",String.valueOf(dishes.getId())).find(Comment.class);//初始化Log.d(TAG,String.valueOf(dishes.getId()));Log.d(TAG,String.valueOf(dishes.getCommentCount()));CommentAdapter adapter=new CommentAdapter(DetailsPage.this,R.layout.comment_menu,commentList);ListView listView=findViewById(R.id.comment_list);listView.setAdapter(adapter);Toast.makeText(DetailsPage.this,"已刷新",Toast.LENGTH_SHORT).show();}}public class addListener implements  View.OnClickListener{User user;Dishes dishes;addListener(User user, Dishes dishes){this.user=user;this.dishes=dishes;}@Overridepublic void onClick(View v) {//触发添加评论事件,记得将评论save,相关的user和dishes的saveIntent intent=new Intent(DetailsPage.this,AddCommentPage.class);Bundle bundle=new Bundle();bundle.putSerializable("dishes1",dishes);bundle.putSerializable("user1",user);Log.d(TAG,dishes.getName()+"1");intent.putExtras(bundle);startActivity(intent);Toast.makeText(DetailsPage.this,"请为此菜品添加评论",Toast.LENGTH_SHORT).show();}}}
 

layout:activity_details_page.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"android:background="#fcfbf4"tools:context=".DetailsPage"><RelativeLayoutandroid:layout_height="wrap_content"android:layout_width="match_parent"android:background="#fcfbf4"android:layout_weight="0"android:layout_marginTop="10dp"><ImageViewandroid:id="@+id/show_dish_image"android:layout_width="200dp"android:layout_height="150dp"android:src="@mipmap/ic_launcher"/><TextViewandroid:id="@+id/show_dish_name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@id/show_dish_image"android:layout_alignTop="@id/show_dish_image"android:text="菜名"android:textSize="25sp"/><TextViewandroid:id="@+id/show_dish_price"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@id/show_dish_image"android:layout_below="@id/show_dish_name"android:layout_marginTop="20dp"android:text="售价"android:textSize="25sp"/><TextViewandroid:id="@+id/show_dish_grade"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@id/show_dish_image"android:layout_below="@id/show_dish_price"android:layout_marginTop="20dp"android:text="评分"android:textSize="25sp"/></RelativeLayout><ListViewandroid:id="@+id/comment_list"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"/><Buttonandroid:id="@+id/add_comment"android:text="添   加   评   论"android:layout_height="35dp"android:layout_weight="0"android:layout_width="match_parent"android:background="#beb391"android:layout_gravity="center_horizontal"android:gravity="center"android:textColor="#e3e6c3"android:textSize="18sp" /><Buttonandroid:id="@+id/f5_comment"android:text="刷   新   评   论"android:layout_height="35dp"android:layout_weight="0"android:layout_width="match_parent"android:background="#beb391"android:layout_gravity="center_horizontal"android:gravity="center"android:textColor="#e3e6c3"android:layout_marginTop="5dp"android:textSize="18sp" /></LinearLayout>

注意:

点击添加评论按钮后跳转到评论界面,评论完毕返回本界面后还需要点击刷新评论按钮新添加的评论才会出现。

八、食堂管理之菜品详细信息界面(可添加评论;ListView)相关推荐

  1. Office 365:如何有效管理会议详细信息和会议纪要

    我的博客地址:https://blog.51cto.com/13637423 如果您的团队尚未使用Microsoft Teams 功能来集中管理与内外部用户组织会议或者整理会议纪要,那么你可以采用Ou ...

  2. 基于微信小程序的大学食堂管理和评价系统

    摘要 近年来,社会对人才的需求越来越多,伴随着高校录取的人数也在不断地扩张,食堂作为高校的重要组成部分,食堂的管理是特别重要的,而在食堂的日常管理中学生的评价声音最多,在校时间一天三个时间段实食堂聚集 ...

  3. cloud foundry_实际的Reactor操作–检索Cloud Foundry应用程序的详细信息

    cloud foundry CF-Java-Client是一个库,可通过程序访问Cloud Foundry Cloud Controller API . 它建立在Project Reactor之上,它 ...

  4. 实际的Reactor操作–检索Cloud Foundry应用程序的详细信息

    CF-Java-Client是一个库,可通过程序访问Cloud Foundry Cloud Controller API . 它建立在Project Reactor之上,它是Reactive Stre ...

  5. SSM项目图书馆管理系统,适合新人练手和毕设参考,功能首页展示 系统注册登录登出 用户管理 权限控制管理 书籍管理 图书借阅管理 个人借阅记录管理 书籍详细信息展示等

    图书馆管理系统,系统采用B/S架构 系统采用框架:java+maven+stringboot+mybatis+mysql-plus+boostart(前端界面) 首页展示 内容后台管理 菜单权限管理 ...

  6. 校园点餐系统:点餐、食堂管理、商户管理和菜品管理(Java和MySQL)

    微信公众号:创享日记 发送关键词:校园点餐系统 获取报告+数据库设计说明+项目源码源文件工程文件 1 实验环境 操作系统:Windows 10,主要开发工具:PowerDesign,MySQL,Ecl ...

  7. Windows 软件授权管理工具检验Windows7激活状态和许可证详细信息

    可用选项: -ipk <产品密钥> 安装产品密钥(替换现有密钥) -upk 卸载产品密钥 -ato 激活 Windows -dli [激活 ID | All] 显示许可证信息(默认: 当前 ...

  8. Banana Pi BPI-R3 评测:详细信息、功能

    Banana Pi BPI-R3 路由板 著名的 Banana Pi 品牌背后的公司 Sinovoip Co., Ltd 刚刚宣布了一款名为 Banana Pi BPI-R3 的带有两个 SFP 端口 ...

  9. 微信公众号开发之网页授权认证获取用户的详细信息,实现自动登陆

    原创声明:本文转来源本人另一博客[http://blog.csdn.net/liaohaojian/article/details/70175835]绝非他人处转载 从接触公众号到现在,开发维护了2个 ...

  10. 用WMI获取远程机器操作系统的详细信息

    使用WMI获取远程机器操作系统的详细信息 大杂烩-.NET 代码主题部分的OperatingSystem类,是使用工具(Management (WMI) Extensions for Visual S ...

最新文章

  1. springboot java.util.NoSuchElementException: No value present 异常处理
  2. 线索二叉树(基于链表存储树结点)
  3. java web 的粗粒度权限管理
  4. SpringBoot环境切换
  5. 程序开发入门工具之CodeBlocks
  6. Helm 3 完整教程(二十三):使用 Files 方法在模板中读取文件内容
  7. 多线程编程(4) - 从 CreateThread 说起[续二]
  8. 【单目标优化求解】基于matlab混沌生物地理算法求解单目标问题【含Matlab源码 1411期】
  9. 安川机器人如何注释化指令_安川机器人命令介绍
  10. unity实用技能,控制renderQueue解决NGUI与Unity3D物体渲染顺序问题
  11. PMS(PackageManagerService)原理简单介绍,启动过程源码简单解析
  12. PrecompiledAssemblyException: Multiple precompiled assemblies with the same name websocket-sharp.dll
  13. 添加js代码:百度网盘网页版开倍速
  14. WSUS服务器不能下载补丁的最终解决办法
  15. vue安装postcss-pxtorem报错
  16. Snipaste截图工具
  17. matlab之列主元素高斯消去法
  18. qq游戏中的“中国象棋2017”闪退原因
  19. Colab平台使用(GPU、挂载、tf版本、运行py脚本、设置点击脚本)
  20. 【开发工具】【JTAG】JTAG基础【一】

热门文章

  1. 直播 | 移动机器人在人居环境下的类人导航
  2. 一周内2家财税解决方案提供商港交所递表 财税数字化赛道热度骤增
  3. 分支-15. 日K蜡烛图
  4. RocketMQ与Kafka差异全面对比
  5. 3.7女生节:被程序员男友送的奇葩礼物宠哭了
  6. 盘点中国式家教的三大悲哀
  7. 百度超级链电子签约平台亮相2020云智峰会,迎接合同签约新生态
  8. 利物浦有望成为全球第一个气候友好城市
  9. java2个啤酒瓶换一瓶啤酒,看看你多快能找到答案?:啤酒2元一瓶,四个瓶盖可换一瓶啤酒,2个空瓶也可换一瓶啤酒,10元最多可以...
  10. 数据结构基础21:堆