Android物联网应用程序开发(智慧城市)—— 查询购物信息界面开发

简介: Android物联网应用程序开发(智慧城市)—— 查询购物信息界面开发

效果:


83.png


布局代码:


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg_environment"
    tools:context=".QueryShopping">
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/btn_inventory_select" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignTop="@id/imageView1"
        android:layout_marginBottom="20dp"
        android:layout_marginRight="20dp"
        android:layout_toRightOf="@id/imageView1"
        android:background="@drawable/bg_frame_descend_setting"
        android:gravity="center_horizontal"
        android:orientation="vertical"
        android:padding="10dip" >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical" >
            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="订单号:"
                android:textColor="@color/white" />
            <EditText
                android:id="@+id/editText1"
                android:layout_width="80dp"
                android:layout_height="24dip"
                android:background="@drawable/input"
                android:padding="2dp"
                android:singleLine="false"
                android:textColor="@color/white" >
                <requestFocus />
            </EditText>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="起始时间:"
                android:textColor="#ffffff" />
            <Button
                android:id="@+id/btnStartTime"
                android:layout_width="100dip"
                android:layout_height="24dip"
                android:background="@drawable/input"
                android:gravity="center"
                android:text="2015-08-01"
                android:textColor="#ffffff" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="结束时间:"
                android:textColor="#ffffff" />
            <Button
                android:id="@+id/btnEndTime"
                android:layout_width="100dip"
                android:layout_height="24dip"
                android:background="@drawable/input"
                android:gravity="center"
                android:text="2015-08-14"
                android:textColor="#ffffff" />
            <Button
                android:id="@+id/btnSearch"
                android:layout_width="142dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:background="@drawable/btn_search" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_marginTop="20dp"
            android:background="@drawable/input"
            android:gravity="center_vertical"
            android:orientation="horizontal" >
            <TextView
                android:id="@+id/tvNo"
                android:layout_width="0.0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:text="订单号"
                android:textColor="@color/white" />
            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#ffffff" />
            <TextView
                android:id="@+id/tvAmount"
                android:layout_width="0.0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="金额"
                android:textColor="@color/white" />
            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#ffffff" />
            <TextView
                android:id="@+id/tvState"
                android:layout_width="0.0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="状态"
                android:textColor="@color/white" />
            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#ffffff" />
            <TextView
                android:id="@+id/tvTime"
                android:layout_width="0.0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:text="添加时间"
                android:textColor="@color/white" />
            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#ffffff" />
            <TextView
                android:id="@+id/tvOperate"
                android:layout_width="0.0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:text="操作"
                android:textColor="@color/white" />
        </LinearLayout>
        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:cacheColorHint="#00000000"
            android:fadingEdgeLength="0dp" >
        </ListView>
    </LinearLayout>
</RelativeLayout>


引用布局:items.xml

<?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" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:gravity="center_vertical"
        android:background="@drawable/input"
        android:orientation="horizontal" >
        <TextView
            android:id="@+id/tvNo"
            android:layout_width="0.0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:textColor="@color/white"
            android:text="订单号" />
        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#ffffff"
            />
        <TextView
            android:id="@+id/tvAmount"
            android:layout_width="0.0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="@color/white"
            android:text="金额" />
        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#ffffff"
            />
        <TextView
            android:id="@+id/tvState"
            android:layout_width="0.0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="@color/white"
            android:text="状态" />
        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#ffffff"
            />
        <TextView
            android:id="@+id/tvTime"
            android:layout_width="0.0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:textColor="@color/white"
            android:text="添加时间" />
        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#ffffff"
            />
        <TextView
            android:id="@+id/tvOperate"
            android:layout_width="0.0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:textColor="@color/white"
            android:text="操作" />
    </LinearLayout>
</LinearLayout>



Java类进行列表项内容的添加


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public abstract class MyAdapter extends BaseAdapter {
    private Context context;
    public MyAdapter(Context context){
        this.context = context;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHoller v;
        if(convertView==null){
            v = new ViewHoller();
            convertView = LayoutInflater.from(context).inflate(R.layout.items, null);
            v.mTvNo = (TextView) convertView.findViewById(R.id.tvNo);
            v.mTvAmount = (TextView) convertView.findViewById(R.id.tvAmount);
            v.mTvState = (TextView)convertView.findViewById(R.id.tvState);
            v.mTvTime = (TextView)convertView.findViewById(R.id.tvTime);
            v.mTvOperate = (TextView)convertView.findViewById(R.id.tvOperate);
            convertView.setTag(v);
        }else{
            v = (ViewHoller) convertView.getTag();
        }
        v.mTvNo.setText("201508281043");
        v.mTvAmount.setText("168");
        v.mTvState.setText("已发货");
        v.mTvTime.setText("2015-08-28 10:43");
        v.mTvOperate.setText("");
        return convertView;
    }
    class ViewHoller{
        TextView mTvNo,mTvAmount,mTvState,mTvTime,mTvOperate;
    }
}


加载列表项


import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
public class QueryShopping extends AppCompatActivity {
private ListView mlistView;
private MyAdapter myAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_query_shopping);
        mlistView = (ListView)findViewById(R.id.listView1);
    }
}


相关实践学习
阿里云AIoT物联网开发实战
本课程将由物联网专家带你熟悉阿里云AIoT物联网领域全套云产品,7天轻松搭建基于Arduino的端到端物联网场景应用。 开始学习前,请先开通下方两个云产品,让学习更流畅: IoT物联网平台:https://iot.console.aliyun.com/ LinkWAN物联网络管理平台:https://linkwan.console.aliyun.com/service-open
目录
相关文章
|
存储 Android开发 数据安全/隐私保护
如何在Android设备上撤销Flutter应用程序的所有权限?
如何在Android设备上撤销Flutter应用程序的所有权限?
1228 64
|
缓存 Android开发 开发者
Flutter环境配置完成后,如何在Android设备上运行Flutter应用程序?
Flutter环境配置完成后,如何在Android设备上运行Flutter应用程序?
3148 62
|
开发工具 Android开发 开发者
在Android设备上运行Flutter应用程序时,如果遇到设备未授权的问题该如何解决?
在Android设备上运行Flutter应用程序时,如果遇到设备未授权的问题该如何解决?
1305 61
|
Java API Android开发
安卓应用程序开发的新手指南:从零开始构建你的第一个应用
【10月更文挑战第20天】在这个数字技术不断进步的时代,掌握移动应用开发技能无疑打开了一扇通往创新世界的大门。对于初学者来说,了解并学习如何从无到有构建一个安卓应用是至关重要的第一步。本文将为你提供一份详尽的入门指南,帮助你理解安卓开发的基础知识,并通过实际示例引导你完成第一个简单的应用项目。无论你是编程新手还是希望扩展你的技能集,这份指南都将是你宝贵的资源。
1331 5
|
传感器 监控 安全
创新无限:物联网技术在智慧城市构建中的前沿探索
【10月更文挑战第29天】在这个信息爆炸的时代,物联网(IoT)技术正重塑我们对城市的认知。智慧城市已从科幻走向现实,物联网通过连接各种设备和传感器,收集、分析数据,提升城市运行效率和居民生活质量。从智慧城管、智能交通、智慧水务到智能电网,物联网的应用正逐步实现城市的智能化、互联化和可持续发展。
574 1
|
存储 XML API
安卓应用程序开发:从新手到专家的旅程
【8月更文挑战第33天】在这篇文章中,我们将一起踏上一段激动人心的旅程,探索如何从一个对安卓应用程序开发一无所知的新手,成长为一个能够独立开发复杂应用程序的专家。我们将通过实际案例和代码示例,深入理解安卓开发的各个方面,包括用户界面设计、数据存储、网络通信等。无论你是刚刚入门,还是已经有一些基础,这篇文章都将为你提供宝贵的知识和技能,帮助你在安卓开发的道路上更进一步。
|
传感器 自动驾驶 物联网
5G+物联网:构建智慧城市的新基石
【9月更文挑战第4天】5G+物联网作为构建智慧城市的新基石,正引领着城市管理的智能化变革。随着技术的不断成熟和应用场景的不断拓展,智慧城市将变得更加智能、高效和可持续。然而,我们也应看到,智慧城市的建设还面临着数据安全、隐私保护等挑战。未来,我们需要加强技术创新和法规建设,确保智慧城市在快速发展的同时,也能够保障人民的安全和权益。
|
传感器 物联网 数据挖掘
物联网在智慧城市交通管理系统中的应用
物联网在智慧城市交通管理系统中的应用
838 1
|
Dart IDE Linux
开发Android应用程序
开发Android应用程序
331 1
|
传感器 物联网 数据安全/隐私保护
智慧城市中的环境监测:物联网的角色
【6月更文挑战第6天】智慧城市中的物联网技术在环境监测中发挥关键作用,如路灯上的传感器实时监测空气质量和气候,智能垃圾桶自动检测垃圾容量。物联网使环境监测更全面、精准,但需解决数据安全、设备可靠性和标准统一等问题。随着科技发展,未来智慧城市将因物联网变得更加绿色宜居,环境监测将与城市各领域深度融合。我们期待科技带来的惊喜变革,为建设美好城市努力。
514 2

相关产品

  • 物联网平台