20212119 2023-2024-2 《移动平台开发与实践》综合实践

20212119 2024-06-29 18:20:38

目录

  • 1 实验内容
  • 1.1 项目介绍
  • 1.2 设计分析
  • 2 实现过程
  • 2.1 Fragment结构分析
  • 2.2 登陆注册界面的实现
  • 2.3 fragment首页界面
  • 2.4 fragment水果界面
  • 2.5 fragment购物车下单界面
  • 2.6 fragment我的界面
  • 2.7 点击事件功能跳转
  • 2.8 搜索框的实现
  • 3 项目展示
  • 4 实践中遇到的问题及解决
  • 5 学习感悟与思考
  • 6 课程总结

1 实验内容

1.1 项目介绍

随着科学技术和社会经济的不断提高,人们对服务的快捷、便利性要求也越来越高,从而对智能手机上的应用软件提出了更高的要求。一个基于安卓技术的水果系统能够为用户提供一个方便日常操作的便捷点餐功能,它能够满足广大手机用户的对日常水果的需要,为需求双方提供了一一个共赢的平台。

1.2 设计分析

本系统正是为了实现手机网上选水果而设计,所包含到的有关技术有:Android平台、MySQL技术、Java语言等技术。能够实现水果查看、我的订单、添加订单、菜单管理、用户管理等作用。用户注册后,登陆客户端即可完成订餐、浏览新鲜瓜果等功能。

2 实现过程

2.1 Fragment结构分析

在开发的过程中,使用Fragment能实现一个界面的多次使用,能加快效率。Fragment可以被认为是Activity界面的一个布局,其依赖于Activity,但是拥有自己的活动事件与生命周期。可以通过替换Activity中的Fragment实现界面的优化处理。
在元素中的android:name属性指定了在布局中要实例化的Fragment。当系统创建这个Activity布局时,它实例化在布局中指定的每一个Fragment,并且分别调用onCreateView(),来获取每个Fragment的布局。然后系统会在Activity布局中插入通过元素中声明直接返回的视图。

2.2 登陆注册界面的实现

Button,TextView,TextEdit,ImageView,RatioButton,scrollview等基本控件的使用;多个Activities之间的切换;使用Android本地数据库来管理用户信息。
设置整个RelativeLayout的内边距为20dp,给界面留白。让编辑框的左边对齐到父控件的左边,右边对齐到父控件的右边,将passwordView放到usernameView的下面,以保证二者的相对位置不变。
主布局为垂直布局,第一个TextView控件布置,显示“用户注册”字样,第一个LinearLayout控件,包含一个TextView控件和EditView控件,用于提醒用户输入和获取账号信息
activity_register.xml


<?xml version="1.0" encoding="utf-8"?>
<!--线性布局  LinearLayout 根布局-->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:fitsSystemWindows="true"
    android:background="#F0F0F0">
    <!--标题栏-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bg_border_bottom">
        <com.example.fruit.widget.ActionBar
            android:id="@+id/myActionBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </LinearLayout>
    <ImageView
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_marginTop="0dp"
        android:layout_marginBottom="10dp"
        android:src="@drawable/a1" />

    <TextView
        android:textSize="30dp"
        android:textColor="#000000"
        android:layout_gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp"
        android:layout_marginBottom="30dp"
        android:text="新用户注册" />
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <!--表单布局-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:orientation="vertical">
            <!--账号-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <!--TextView 文本  html的p标签-->
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:text="账 号:"
                    android:textColor="#000000"
                    android:textSize="20dp" />

                <EditText
                    android:id="@+id/et_account"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"

                    android:textSize="14dp"
                    android:singleLine="true"
                    android:hint="请输入账号" />
            </LinearLayout>
            <!--昵称-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <!--TextView 文本  html的p标签-->
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:text="昵 称:"
                    android:textColor="#000000"
                    android:textSize="20dp"/>

                <EditText
                    android:id="@+id/et_nickName"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"

                    android:textSize="14dp"
                    android:singleLine="true"
                    android:hint="请输入昵称" />
            </LinearLayout>
            <!--年龄-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <!--TextView 文本  html的p标签-->
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:text="电 话:"

                    android:textColor="#000000"
                    android:textSize="20dp" />

                <EditText
                    android:id="@+id/et_age"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"
                    android:inputType="number"
                    android:textSize="14dp"
                    android:singleLine="true"
                    android:hint="请输入电话" />
            </LinearLayout>
            <!--邮箱-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <!--TextView 文本  html的p标签-->
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:text="收货地址:"
                    android:textColor="#000000"
                    android:textSize="20dp" />

                <EditText
                    android:id="@+id/et_email"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"

                    android:textSize="14dp"
                    android:inputType="textEmailAddress"
                    android:singleLine="true"
                    android:hint="请输入地址:xx省xx市xx区/县" />
            </LinearLayout>
            <!--密码-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:textSize="20dp"
                    android:textColor="#000000"
                    android:text="密 码:"/>
                <EditText
                    android:id="@+id/et_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPassword"

                    android:textSize="14dp"
                    android:singleLine="true"
                    android:hint="请输入密码"/>
            </LinearLayout>
            <!--确认密码-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:textSize="20dp"
                    android:textColor="#000000"
                    android:text="确认密码:"/>
                <EditText
                    android:id="@+id/et_password_sure"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPassword"

                    android:textSize="14dp"
                    android:singleLine="true"
                    android:hint="请输入密码"/>
            </LinearLayout>

            <!--注册按钮-->
            <Button
                android:id="@+id/btn_register"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="50dp"
                android:background="@drawable/btn_border_fill"
                android:textColor="@color/colorWhite"
                android:textSize="22dp"
                android:textAllCaps="false"
                android:text="注 册"/>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

activity_login.xml


<?xml version="1.0" encoding="utf-8"?>
<!--线性布局  LinearLayout 根布局-->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:fitsSystemWindows="true"
    android:background="#F0F0F0">
    <!--标题栏-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bg_border_bottom">
        <com.example.fruit.widget.ActionBar
            android:id="@+id/myActionBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </LinearLayout>
    <ImageView
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_marginTop="0dp"
        android:layout_marginBottom="10dp"
        android:src="@drawable/a1" />

    <TextView
        android:textSize="30dp"
        android:textColor="#000000"
        android:layout_gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp"
        android:layout_marginBottom="30dp"
        android:text="新用户注册" />
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <!--表单布局-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:orientation="vertical">
            <!--账号-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <!--TextView 文本  html的p标签-->
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:text="账 号:"
                    android:textColor="#000000"
                    android:textSize="20dp" />

                <EditText
                    android:id="@+id/et_account"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"

                    android:textSize="14dp"
                    android:singleLine="true"
                    android:hint="请输入账号" />
            </LinearLayout>
            <!--昵称-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <!--TextView 文本  html的p标签-->
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:text="昵 称:"
                    android:textColor="#000000"
                    android:textSize="20dp"/>

                <EditText
                    android:id="@+id/et_nickName"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"

                    android:textSize="14dp"
                    android:singleLine="true"
                    android:hint="请输入昵称" />
            </LinearLayout>
            <!--年龄-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <!--TextView 文本  html的p标签-->
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:text="电 话:"

                    android:textColor="#000000"
                    android:textSize="20dp" />

                <EditText
                    android:id="@+id/et_age"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"
                    android:inputType="number"
                    android:textSize="14dp"
                    android:singleLine="true"
                    android:hint="请输入电话" />
            </LinearLayout>
            <!--邮箱-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <!--TextView 文本  html的p标签-->
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:text="收货地址:"
                    android:textColor="#000000"
                    android:textSize="20dp" />

                <EditText
                    android:id="@+id/et_email"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"

                    android:textSize="14dp"
                    android:inputType="textEmailAddress"
                    android:singleLine="true"
                    android:hint="请输入地址:xx省xx市xx区/县" />
            </LinearLayout>
            <!--密码-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:textSize="20dp"
                    android:textColor="#000000"
                    android:text="密 码:"/>
                <EditText
                    android:id="@+id/et_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPassword"

                    android:textSize="14dp"
                    android:singleLine="true"
                    android:hint="请输入密码"/>
            </LinearLayout>
            <!--确认密码-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_border_bottom"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:orientation="horizontal">
                <TextView
                    android:layout_width="95dp"
                    android:layout_height="wrap_content"
                    android:gravity="start"
                    android:textSize="20dp"
                    android:textColor="#000000"
                    android:text="确认密码:"/>
                <EditText
                    android:id="@+id/et_password_sure"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPassword"

                    android:textSize="14dp"
                    android:singleLine="true"
                    android:hint="请输入密码"/>
            </LinearLayout>

            <!--注册按钮-->
            <Button
                android:id="@+id/btn_register"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="50dp"
                android:background="@drawable/btn_border_fill"
                android:textColor="@color/colorWhite"
                android:textSize="22dp"
                android:textAllCaps="false"
                android:text="注 册"/>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

img

img

2.3 fragment首页界面

Fragment_home.xml布局文件添加控件ImageView,EditText,match parent, 父布局来决定当前控件的大小 wrap parent控件内容决定当前控件的大小android:background修改背景图片,界面美观整洁

img

2.4 fragment水果界面

Fragment_snack.xml中LinearLayout线性布局,添加控件ImageView,TextView,Button,插入图片,添加文字,按钮的组件互通

img

2.5 fragment购物车下单界面


public void onClick(View v) {
        Orders order = new Orders(account,fruit.getTitle(),"S"+ System.currentTimeMillis(),account,sf.format(new Date()));
        order.save();
        Toast.makeText(mActivity,"订单成功", Toast.LENGTH_SHORT).show();
        btnCollect.setVisibility(View.GONE);
        btnCancel.setVisibility(View.VISIBLE);
    }
});
//取消收藏
btnCancel.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Orders order = DataSupport.where("account = ? and title = ?",account,fruit.getTitle()).findFirst(Orders.class);
        order.delete();
        Toast.makeText(mActivity,"取消成功", Toast.LENGTH_SHORT).show();
        btnCollect.setVisibility(View.VISIBLE);
        btnCancel.setVisibility(View.GONE);

img

2.6 fragment我的界面

ScollViiew布局控件设置滚动条,线性布局textview控件编写:我的订单、待付款、待评价、退款,EditText用户和应用的传输数据进行修改地址,checkbox:复选框添加备注,radioggroup存放着Radiobutton控件。LinearLayout线性布局,添加多个button按钮layout_width,textColor,background,layout_height布局高度、宽度、文本颜色,背景。


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

        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_marginTop="0dp"
        android:layout_marginBottom="50dp"
        android:src="@drawable/a1" />


    <!--列表-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <LinearLayout
            android:id="@+id/person"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_ripple"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:layout_marginTop="10dp"
            android:orientation="horizontal">
            <ImageView
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:layout_gravity="center"
                android:src="@drawable/main_user_press"/>
            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginLeft="10dp"
                android:text="个人信息"
                android:textSize="14dp"
                android:textColor="@color/colorBlack"
                android:layout_gravity="center_vertical"/>
            <ImageView
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:layout_gravity="center"
                android:src="@drawable/ic_right"/>
        </LinearLayout>
          <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <LinearLayout
            android:id="@+id/manage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_ripple"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:layout_marginTop="10dp"
            android:orientation="horizontal">
            <ImageView
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:layout_gravity="center"
                android:src="@drawable/manage"/>
            <TextView
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:layout_marginLeft="10dp"
                android:text="用户管理"
                android:textSize="14dp"
                android:textColor="@color/colorBlack"
                android:layout_gravity="center_vertical"/>
            <ImageView
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:layout_gravity="center"
                android:src="@drawable/ic_right"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <LinearLayout
                android:id="@+id/order"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_ripple"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:layout_marginTop="10dp"
                android:orientation="horizontal">
                <ImageView
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:layout_gravity="center"
                    android:src="@drawable/dingdan"/>
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_marginLeft="10dp"
                    android:text="我的订单"
                    android:textSize="14dp"
                    android:textColor="@color/colorBlack"
                    android:layout_gravity="center_vertical"/>
                <ImageView
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_right"/>
            </LinearLayout>
            <LinearLayout
                android:id="@+id/browse"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/bg_ripple"
                android:orientation="horizontal"
                android:paddingLeft="20dp"
                android:paddingTop="10dp"
                android:paddingRight="20dp"
                android:paddingBottom="10dp">

                <ImageView
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_browse" />

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_marginLeft="10dp"
                    android:layout_weight="1"
                    android:text="浏览记录"
                    android:textColor="@color/colorBlack"
                    android:textSize="14dp" />

                <ImageView
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_right" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/security"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_ripple"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:layout_marginTop="10dp"
                android:orientation="horizontal">
                <ImageView
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_security"/>
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_marginLeft="10dp"
                    android:text="账号安全"
                    android:textSize="14dp"
                    android:textColor="@color/colorBlack"
                    android:layout_gravity="center_vertical"/>
                <ImageView
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_right"/>
            </LinearLayout>
            <LinearLayout
                android:id="@+id/favorite"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bg_ripple"
                android:paddingTop="10dp"
                android:paddingBottom="10dp"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:layout_marginTop="10dp"
                android:orientation="horizontal">
                <ImageView
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:layout_gravity="center"
                    android:src="@drawable/kefu"/>
                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_marginLeft="10dp"
                    android:text="联系客服"
                    android:textSize="14dp"
                    android:textColor="@color/colorBlack"
                    android:layout_gravity="center_vertical"/>
                <ImageView
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_right"/>
            </LinearLayout>
        </LinearLayout>
        <Button
            android:id="@+id/logout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="退出登录"
            android:background="@drawable/btn_border_fill"
            android:textSize="18dp"
            android:textColor="@color/colorWhite"
            android:layout_marginTop="100dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"/>
    </LinearLayout>
</LinearLayout>
</LinearLayout>

img

2.7 点击事件功能跳转

<Button//按钮添加
android:text="设置"//文本名称
android:id="@+id/my_btn6"//id为btn的控件索引
创建一个我的myFragement的classl类的java文件extends Fragment子类继承父类.
onCreateView()fragment创建frag对应视图
Inflate加载layout布局文件fragment_my
findViewById (R.id.my_btn6); 引用.R文件里的引用名
setOnClickListener添加一个点击事件监听器
onClick{intent组件互通跳转activity .java界面
startActivity(intent);启动

img

2.8 搜索框的实现

整个布局使用的是线性布局,搜索框又是一个线性布局(里面包含一个相对布局和一个TextView,相对布局里面有一个EditText和ImageVIew),搜索框其实就是一个EditText


public void onClick(View v) {
              //如果输入框内容为空,提示请输入搜索内容
ToastUtils.showToast(context,"输入查询关键字");
}else {//判断cursor是否为空
                    if (cursor != null) {
                     int columnCount = cursor.getCount();
                      if (columnCount == 0) {
ToastUtils.showToast(context, "对不起,没有你要搜索的内容");
private void showListView() {
        mListView.setVisibility(View.VISIBLE); //获得输入的内容
        String str = mEditText.getText().toString().trim();
        //获取数据库对象

img

3 项目展示

4 实践中遇到的问题及解决

问题1:图表的实现
问题1解决方案:仅靠java代码难以设计出想象的界面,所以我使用了MYSQL库

5 学习感悟与思考

这次综合实践非常仓促,我只根据以前的项目做了一些基础的改编,留下了注册登录系统,做了水果购买系统,由于临近期末,时间精力有限,所以设想的功能只实现了一部分,比如支付系统。实现的功能都是较为基础的。其中遇到的难题我会和同学一起讨论克服解决难关,从开始的无从下手,到初见雏形,再到基本完善,还查阅了很多资料。这次实践也是对我过去所学的应用与总结。希望以后我能克服困难,设计出更优秀的系统。

6 课程总结

随着移动互联网的飞速发展,安卓移动平台开发已成为IT领域的重要分支。本学期,我有幸选修了安卓移动平台开发课程,通过系统的学习和实践,我对安卓开发有了更深入的了解。在课程中我们学习了了安卓开发的基础知识、四大组件、界面设计、数据存储等多个方面。这门课没有停留在课本阶段,在课堂之外,丰富的实验帮助我巩固加深了所学的知识,对我开发项目带来了许多启发。

课程初期,我们学习了安卓开发的基础:安卓系统的架构,并且自己完成了开发环境搭建,在Java编程语言的基础进一步学习了kotlin语言。我一步一个脚印,安装了Android Studio,配置了虚拟机,并且成功实现了第一个项目。接着我们学习了Kotlin语言,相比Java语言,Kotlin语言更加简洁,便于Android开发。
接着,我们重点学习了安卓四大组件:深入学习了Activity、Service、BroadcastReceiver、Content Provider等核心组件的工作原理和使用方法。在实验和作业中,我们学会了运用这些插件。
志强老师的上课方式让我感到非常轻松,学习效率也很高,尤其注重理论与实践相结合,通过大量的实践,使我能够将所学知识应用于实际开发中。在实践中,我遇到了很多问题,但通过查阅资料和同学间的讨论,我逐渐找到了解决问题的方法,也加深了对知识的理解。
安卓开发是一个不断发展的领域,新的技术和框架不断涌现。为了跟上时代的步伐,我们需要保持持续学习的态度。在课程学习中,我接触到了许多新的技术和工具,这激发了我对安卓开发的兴趣和热情。
通过本学期的学习,我掌握了安卓开发的基本知识和技能,能够独立完成简单的安卓应用开发。同时,我也提高了自己的编程能力和解决问题的能力。在课程项目中,我完成了一个基于安卓平台的在线水果购物应用,该应用实现了商品浏览、购买、支付等功能。在项目开发过程中,我不仅提高了自己的技术水平,还学会了尽量在最短的时间内完成项目(o(╥﹏╥)o)。本学期安卓移动平台开发课程的学习让我收获颇丰。我不仅掌握了安卓开发的基本知识和技能,还提高了自己的编程能力和解决问题的能力。感谢老师的悉心教导和同学们的帮助与支持。在未来的学习和工作中,我将继续努力、不断进步!

...全文
206 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

102

社区成员

发帖
与我相关
我的任务
社区描述
实验报告
android 高校
社区管理员
  • blackwall0321
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧