智能农业项目简介

本文档总结了智能农业项目的实施过程,包括在build.gradle中添加依赖,创建页面布局,如将CO2界面的方形图片转为圆形。还详细介绍了Java文件的使用,如fragment、gson和util,以及如何通过OKHttp实现网络请求,获取和解析实时信息。此外,项目实现了开关控制功能,通过点击按钮控制设施状态,并利用标识位保持界面状态。公共类和全局变量的合理使用简化了网络请求的代码。
摘要由CSDN通过智能技术生成

智能农业项目总结

首先,先在build.gradle添加项目所需要的所有的数据包
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
一.创建页面布局,实现界面转换(举例首页布局)
<RelativeLayout 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"    tools:context="android.coolweather2.com.agriculturedemo.fragment.HomePageFragment">

    <TextView
        android:id="@+id/home_page_top_lin"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center_horizontal"
        android:text="智能农业"
        android:textColor="#24bd3b"
        android:textSize="30dp" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/main_bottom_lin"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/home_page_top_lin"
        android:overScrollMode="never"
        android:scrollbars="none">

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

            <android.support.v4.view.ViewPager
                android:id="@+id/home_page_vp"
                android:layout_width="match_parent"
                android:layout_height="150dp">
            </android.support.v4.view.ViewPager>

            <View
                android:layout_width="match_parent"
                android:layout_height="20dp" />

            <include layout="@layout/co2" />

            <View
                android:layout_width="match_parent"
                android:layout_height="20dp" />

            <include layout="@layout/light" />

            <View
                android:layout_width="match_parent"
                android:layout_height="20dp" />

            <include layout="@layout/soil" />

            <View
                android:layout_width="match_parent"
                android:layout_height="20dp" />

            <include layout="@layout/air" />

        </LinearLayout>
    </ScrollView>
</RelativeLayout>
CO2界面代码(将方形图片转换成圆形图片)
<?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="wrap_content"
    android:orientation="vertical"
    xmlns:app="http://sche
  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值