关于体温app,比较难的是获取定位信息,剩下的就是增删改查。

设计思路:首先布局一个添加页面,给每个元件添加id,之后在获取地点的EditText获取位置信息,在添加两个布局文件,体现在一个页面里用来记录每天的体温,并且可以修改每日的信息。

源程序代码(底下有链接):

MainActivity.java(之前的小程序在判断添加的数据和修改数据的时候有点bug,现已修改)

用于添加数据

package com.example.temperature;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast; import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;
import com.example.temperature.adapter.Temp;
import com.example.temperature.dao.UserDao;
import com.example.temperature.model.User; import java.text.SimpleDateFormat;
import java.util.Date; public class MainActivity extends AppCompatActivity {
private Button btn_submit;
private Button btn_adr;
private Button btn_back;
private EditText et_name;
private TextView tv_time;
private EditText et_temperature;
private EditText et_place;
private RadioGroup rg_gender;
private RadioButton radioButton;
private LocationService locationService;
private MysqliteOpenHelper dbHelper;
private MysqliteOpenHelper dbHelper1;
private User edititem=null;
private UserDao userDao;
private RadioButton rb_boy;
private RadioButton rb_girl;
private String waterIn;
Date date=new Date();
SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyy-MM-dd");
String time = simpleDateFormat.format(date);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); initUI();
initData(); locationService = new LocationService(this);
locationService.registerListener(mListener);
locationService.setLocationOption(locationService.getDefaultLocationClientOption());
}
public void initUI(){
btn_submit=findViewById(R.id.btn_submit);
et_name=findViewById(R.id.et_name);
tv_time=findViewById(R.id.tv_time);
et_temperature=findViewById(R.id.et_temperature);
et_place=findViewById(R.id.et_place);
rg_gender=findViewById(R.id.rg_gender);
btn_adr=findViewById(R.id.btn_adr);
btn_back=findViewById(R.id.btn_back);
rg_gender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
radioButton = (RadioButton)findViewById(rg_gender.getCheckedRadioButtonId());
waterIn = radioButton.getText().toString();
Log.i("radio", waterIn);
}
});
btn_submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// radioButton = (RadioButton)findViewById(rg_gender.getCheckedRadioButtonId());
UserDao userDao=new UserDao(MainActivity.this);
String name=et_name.getText().toString();
String gender=waterIn;
String temperature=et_temperature.getText().toString();
String place=et_place.getText().toString();
if(name.trim().length()==0){
Toast.makeText(MainActivity.this,"姓名不能为空",Toast.LENGTH_SHORT).show();
return;
}
if(rg_gender.getCheckedRadioButtonId()==(-1)){
Toast.makeText(MainActivity.this,"性别不能为空",Toast.LENGTH_SHORT).show();
return;
}
System.out.println(rg_gender.getCheckedRadioButtonId());
if(temperature.trim().length()==0){
Toast.makeText(MainActivity.this,"体温不能为空",Toast.LENGTH_SHORT).show();
return;
}
if(place.trim().length()==0){
Toast.makeText(MainActivity.this,"地点不能为空",Toast.LENGTH_SHORT).show();
return;
}
if(edititem==null){
User u=new User(0,time,name,gender,temperature,place);
boolean f=userDao.insert(u);
if(f){
Toast.makeText(MainActivity.this,"提交成功",Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(MainActivity.this,"提交失败",Toast.LENGTH_SHORT).show();
}
}
else{
//String time_true=userDao.queryTime();
edititem.setTime(edititem.getTime());
edititem.setName(name);
edititem.setTemperature(temperature);
edititem.setPlace(place);
edititem.setGender(gender);
userDao.updateContacter(edititem);
}
// locationService.stop();
finish();
}
});
btn_adr.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
locationService.start();
}
});
btn_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
public void initData(){
rb_boy=findViewById(R.id.rb_boy);
rb_girl=findViewById(R.id.rb_girl);
userDao=new UserDao(MainActivity.this);
edititem=(User)getIntent().getSerializableExtra("edititem");
if(edititem==null){
tv_time.setText(time);
}
if(edititem!=null){
et_name.setText(edititem.getName());
et_temperature.setText(edititem.getTemperature());
et_place.setText(edititem.getPlace());
if(rb_boy.getText().toString().equals(edititem.getGender())) ((RadioButton) rg_gender.findViewById(R.id.rb_boy)).setChecked(true);
if((rb_girl.getText().toString()).equals(edititem.getGender())) ((RadioButton) rg_gender.findViewById(R.id.rb_girl)).setChecked(true);
tv_time.setText(edititem.getTime());
System.out.println(edititem.getTime()+"77");
}
}
@Override
protected void onDestroy() {
super.onDestroy();
locationService.unregisterListener(mListener); //注销掉监听
locationService.stop(); //停止定位服务
} /*****
*
* 定位结果回调,重写onReceiveLocation方法,可以直接拷贝如下代码到自己工程中修改
*
*/
private BDAbstractLocationListener mListener = new BDAbstractLocationListener() { @Override
public void onReceiveLocation(BDLocation location) {
// TODO Auto-generated method stub
if (null != location && location.getLocType() != BDLocation.TypeServerError) {
//button.setText("停止定位");
StringBuilder sb = new StringBuilder(256);
/**
* 时间也可以使用systemClock.elapsedRealtime()方法 获取的是自从开机以来,每次回调的时间;
* location.getTime() 是指服务端出本次结果的时间,如果位置不发生变化,则时间不变
*/ sb.append(location.getAddrStr());
if (location.getLocType() == BDLocation.TypeGpsLocation) {
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 网络定位结果
// 运营商信息
if (location.hasAltitude()) {// *****如果有海拔高度*****
sb.append("\nheight : ");
sb.append(location.getAltitude());// 单位:米
}
} else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果
sb.append("\ndescribe : ");
sb.append("离线定位成功,离线定位结果也是有效的");
} else if (location.getLocType() == BDLocation.TypeServerError) {
sb.append("\ndescribe : ");
sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到loc-bugs@baidu.com,会有人追查原因");
} else if (location.getLocType() == BDLocation.TypeNetWorkException) {
sb.append("\ndescribe : ");
sb.append("网络不同导致定位失败,请检查网络是否通畅");
} else if (location.getLocType() == BDLocation.TypeCriteriaException) {
sb.append("\ndescribe : ");
sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机");
}
logMsg(sb.toString());
}
} }; /**
* 显示请求字符串
*/
public void logMsg(final String str) {
try {
new Thread(new Runnable() {
@Override
public void run() {
et_place.post(new Runnable() {
@Override
public void run() {
et_place.setText(str);
}
});
}
}).start();
} catch (Exception e) {
e.printStackTrace();
}
} }

IndexActivity.java(添加RecyclerView的设置)

package com.example.temperature;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button; import com.example.temperature.adapter.Temp;
import com.example.temperature.dao.UserDao;
import com.example.temperature.model.User; import java.util.List; public class IndexActivity extends AppCompatActivity implements View.OnClickListener{
private Button btn_back;
private Button btn_add;
private Button tv_time;
private LocationService locationService;
private RecyclerView rec;
private UserDao userDao;
private Temp adapter;
private final Activity mContext=IndexActivity.this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_index);
initUI();
initData();
}
@Override
protected void onResume() {
super.onResume();
adapter.setList(userDao.queryAll());
adapter.notifyDataSetChanged();
}
public void initUI(){
btn_back=findViewById(R.id.btn_back);
btn_add=findViewById(R.id.btn_add);
btn_back.setOnClickListener(this);
btn_add.setOnClickListener(this); rec=findViewById(R.id.rec);
rec.setLayoutManager(new LinearLayoutManager(mContext));
DividerItemDecoration divider = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
divider.setDrawable(ContextCompat.getDrawable(this,R.drawable.recycler_item));
rec.addItemDecoration(divider);
}
private void initData(){
userDao =new UserDao(mContext);
List<User> list=userDao.queryAll();
adapter=new Temp(mContext,list);
rec.setAdapter(adapter);
}
@Override
public void onClick(View v) {
int id=v.getId();
Intent intent=new Intent();
switch (id){
case R.id.btn_back:finish();break;
case R.id.btn_add:
intent.setClass(IndexActivity.this,MainActivity.class);
startActivity(intent);
break;
}
}
}

LocationService.java(用于定位的服务)

package com.example.temperature;

import android.content.Context;

import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.location.LocationClientOption.LocationMode; public class LocationService {
private LocationClient client = null;
private LocationClientOption mOption,DIYoption;
private Object objLock = new Object(); public LocationService(Context locationContext){
synchronized (objLock) {
if(client == null){
client = new LocationClient(locationContext);
client.setLocOption(getDefaultLocationClientOption());
}
}
} // 注册
public boolean registerListener(BDAbstractLocationListener listener){
boolean isSuccess = false;
if(listener != null){
client.registerLocationListener(listener);
isSuccess = true;
}
return isSuccess;
} // 注销
public void unregisterListener(BDAbstractLocationListener listener){
if(listener != null){
client.unRegisterLocationListener(listener);
}
} //设置配置
public boolean setLocationOption(LocationClientOption option){
boolean isSuccess = false;
if(option != null){
if(client.isStarted())
client.stop();
DIYoption = option;
client.setLocOption(option);
}
return isSuccess;
} //默认Option设置
public LocationClientOption getDefaultLocationClientOption(){
if(mOption == null){
mOption = new LocationClientOption();
mOption.setLocationMode(LocationMode.Hight_Accuracy);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
mOption.setCoorType("bd09ll");//可选,默认gcj02,设置返回的定位结果坐标系,如果配合百度地图使用,建议设置为bd09ll;
mOption.setScanSpan(3000);//可选,默认0,即仅定位一次,设置发起连续定位请求的间隔需要大于等于1000ms才是有效的
mOption.setIsNeedAddress(true);//可选,设置是否需要地址信息,默认不需要
mOption.setIsNeedLocationDescribe(true);//可选,设置是否需要地址描述
mOption.setNeedDeviceDirect(false);//可选,设置是否需要设备方向结果
mOption.setLocationNotify(false);//可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
mOption.setIgnoreKillProcess(true);//可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
mOption.setIsNeedLocationDescribe(true);//可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近”
mOption.setIsNeedLocationPoiList(true);//可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到
mOption.SetIgnoreCacheException(false);//可选,默认false,设置是否收集CRASH信息,默认收集
mOption.setOpenGps(true);//可选,默认false,设置是否开启Gps定位
mOption.setIsNeedAltitude(false);//可选,默认false,设置定位时是否需要海拔信息,默认不需要,除基础定位版本都可用
}
return mOption;
} //自定义Option设置
public LocationClientOption getOption(){
if(DIYoption == null) {
DIYoption = new LocationClientOption();
}
return DIYoption;
} public void start(){
synchronized (objLock) {
if(client != null && !client.isStarted()){
client.start();
}
}
}
public void stop(){
synchronized (objLock) {
if(client != null && client.isStarted()){
client.stop();
}
}
} public boolean isStart() {
return client.isStarted();
} public boolean requestHotSpotState(){
return client.requestHotSpotState();
}
}

model.User.java(封装)

package com.example.temperature.model;

import java.io.Serializable;

public class User implements Serializable {
private Integer id;
private String time;
private String name;
private String gender;
private String temperature;
private String place; public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getTime() {
return time;
} public void setTime(String time) {
this.time = time;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getGender() {
return gender;
} public void setGender(String gender) {
this.gender = gender;
} public String getTemperature() {
return temperature;
} public void setTemperature(String temperature) {
this.temperature = temperature;
} public String getPlace() {
return place;
} public void setPlace(String place) {
this.place = place;
} public User(Integer id, String time, String name, String gender, String temperature, String place) {
this.id = id;
this.time = time;
this.name = name;
this.gender = gender;
this.temperature = temperature;
this.place = place;
} public User() {
} @Override
public String toString() {
return "User{" +
"id=" + id +
", time='" + time + '\'' +
", name='" + name + '\'' +
", gender='" + gender + '\'' +
", temperature='" + temperature + '\'' +
", place='" + place + '\'' +
'}';
}
}

dao.UserDao.java(方法,连接数据库)

package com.example.temperature.dao;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import androidx.annotation.Nullable; import com.example.temperature.MysqliteOpenHelper;
import com.example.temperature.model.User; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List; public class UserDao {
private MysqliteOpenHelper helper;
public UserDao(Context context){
helper=new MysqliteOpenHelper(context);
} public boolean updateContacter(User u) {
SQLiteDatabase db=helper.getReadableDatabase();
// String sql="select *from user where account='"+account+"' and password='"+password+'"';
ContentValues values=new ContentValues();
values.put("name",u.getName());
values.put("temperature",u.getTemperature());
values.put("time",u.getTime());
values.put("place",u.getPlace());
values.put("gender",u.getGender()); long update= db.update("user",values,"id=?",new String[]{u.getId()+""});
System.out.println(u.getId()+"年号");
return update>0;
} public boolean insert(User u){
SQLiteDatabase db=helper.getReadableDatabase();
Date date=new Date();
SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyy-MM-dd");
String time = simpleDateFormat.format(date);
ContentValues values=new ContentValues();
values.put("time",u.getTime());
values.put("name",u.getName());
values.put("gender",u.getGender());
values.put("temperature",u.getTemperature());
values.put("place",u.getPlace());
long insert= db.insert("user",null,values);
System.out.println(u.getPlace());
return insert>0;
}
public List<User> queryAll(){
List<User> list=new ArrayList<>();
User bean=null;
SQLiteDatabase db=helper.getReadableDatabase();
Cursor c=db.query("user",null,null,null,null,null,null);
if(c!=null&&c.getCount()>0){
list=new ArrayList<>();
while(c.moveToNext()){
bean=new User();
bean.setName(c.getString(c.getColumnIndex("name")));
bean.setTime(c.getString(c.getColumnIndex("time")));
bean.setGender(c.getString(c.getColumnIndex("gender")));
bean.setPlace(c.getString(c.getColumnIndex("place")));
bean.setTemperature(c.getString(c.getColumnIndex("temperature")));
bean.setId(c.getInt(c.getColumnIndex("id")));
list.add(bean);
}
}
return list;
}
}

MysqliteOpenHelper.java(创建数据库,创建表)

package com.example.temperature;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import androidx.annotation.Nullable; public class MysqliteOpenHelper extends SQLiteOpenHelper { public MysqliteOpenHelper(@Nullable Context context) {
super(context, "temp.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table user(id INTEGER PRIMARY KEY AUTOINCREMENT,time VARCHAR(40),name VARCHAR(20),gender VARCHAR(20),temperature VARCHAR(20),place VARCHAR(220))");
// db.execSQL("create table contacter(id INTEGER PRIMARY KEY AUTOINCREMENT,name VARCHAR(20),phone VARCHAR(20),pic INTEGER(20))");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { }
}

adapter.Temp.java(RecyclerView的adapter适配器的使用)

package com.example.temperature.adapter;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView; import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.recyclerview.widget.RecyclerView; import com.example.temperature.MainActivity;
import com.example.temperature.R;
import com.example.temperature.model.User; import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; public class Temp extends RecyclerView.Adapter<Temp.TempViewHolder>{ private Context mContext;
private List<User> list;
public Temp (Context context, List<User> list){
this.mContext=context;
this.list=list;
}
public void setList(List<User> list) {
this.list=list;
}
@NonNull
@Override
public TempViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
TempViewHolder holder=new TempViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_recycler_view,parent,false));
return holder; } @Override
public void onBindViewHolder(@NonNull TempViewHolder holder, int position) {
User item=list.get(position);
holder.tv_name.setText("姓名:"+item.getName());
holder.tv_time.setText(item.getTime());
holder.tv_temp.setText("体温:"+item.getTemperature());
holder.btn_edit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent();
intent.setClass(mContext, MainActivity.class);
intent.putExtra("edititem",item);
mContext.startActivity(intent);
}
});
} @Override
public int getItemCount() {
return list==null?0:list.size();
} //绑定单元格空间
class TempViewHolder extends RecyclerView.ViewHolder{
TextView tv_name;
TextView tv_time;
TextView tv_temp;
EditText et_name;
EditText et_gender;
EditText et_place;
EditText et_temperature;
Button btn_edit; public TempViewHolder(@NonNull View itemView) {
super(itemView);
tv_name=itemView.findViewById(R.id.tv_name);
tv_time=itemView.findViewById(R.id.tv_time);
tv_temp=itemView.findViewById(R.id.tv_temp);
btn_edit=itemView.findViewById(R.id.btn_edit); }
} }

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@mipmap/ic_great"> <LinearLayout
android:id="@+id/canzhao1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/canzhao2"
android:layout_marginBottom="48dp"
android:gravity="center"
android:orientation="horizontal"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="日期:"
android:textColor="@color/cardview_dark_background"
android:textSize="20sp" /> <TextView
android:id="@+id/tv_time"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="666"
android:textColor="@color/cardview_dark_background"
/>
</LinearLayout> <LinearLayout
android:id="@+id/canzhao2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/linearLayout3"
android:layout_marginBottom="48dp"
android:gravity="center"
android:orientation="horizontal"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名:"
android:textColor="@color/cardview_dark_background"
android:textSize="20sp" /> <EditText
android:id="@+id/et_name"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:hint="请输入姓名"
android:textColorHint="@color/cardview_dark_background" />
</LinearLayout> <LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_above="@+id/linearLayout4"
android:layout_marginBottom="48dp"
android:gravity="center"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="性别:"
android:textColor="@color/cardview_dark_background"
android:textSize="20sp" /> <RadioGroup
android:id="@+id/rg_gender"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:orientation="horizontal"> <RadioButton
android:id="@+id/rb_boy"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:text="男" /> <RadioButton
android:id="@+id/rb_girl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女" />
</RadioGroup>
</LinearLayout> <LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/linearLayout5"
android:layout_marginBottom="48dp"
android:gravity="center"
android:orientation="horizontal"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="体温:"
android:textColor="@color/cardview_dark_background"
android:textSize="20sp" /> <EditText
android:id="@+id/et_temperature"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:hint="请输入体温(例如:36.5)"
android:textColorHint="@color/cardview_dark_background"/>
</LinearLayout> <LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/canzhao6"
android:layout_marginBottom="48dp"
android:gravity="center"
android:orientation="horizontal"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="地点:"
android:textColor="@color/cardview_dark_background"
android:textSize="20sp" /> <EditText
android:id="@+id/et_place"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:hint="请输入地点"
android:textColorHint="@color/cardview_dark_background"/>
</LinearLayout> <LinearLayout
android:id="@+id/canzhao6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="80dp"
android:gravity="center"> <Button
android:id="@+id/btn_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="提交" />
</LinearLayout> <LinearLayout
android:id="@+id/canzhao7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/canzhao1"
android:layout_marginBottom="50dp"
android:gravity="center"
android:orientation="vertical"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="每日体温填报表"
android:textColor="@color/cardview_dark_background"
android:textSize="20sp" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="(请以实际情况填写)"
android:textSize="15sp" />
</LinearLayout>
<Button
android:id="@+id/btn_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="返回" /> <Button
android:id="@+id/btn_adr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="获取定位" /> </RelativeLayout>

activity_index.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".IndexActivity"
android:background="@mipmap/ic_great"> <Button
android:id="@+id/btn_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:layout_marginEnd="3dp"
android:layout_marginRight="3dp"
android:text="填写"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> <androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="56dp" /> <Button
android:id="@+id/btn_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:layout_marginLeft="3dp"
android:layout_marginTop="1dp"
android:text="返回"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> <TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="85dp"
android:layout_marginLeft="85dp"
android:layout_marginTop="14dp"
android:layout_marginEnd="85dp"
android:layout_marginRight="85dp"
android:text="体温填写情况"
app:layout_constraintEnd_toStartOf="@+id/btn_add"
app:layout_constraintStart_toEndOf="@+id/btn_back"
app:layout_constraintTop_toTopOf="parent" /> <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rec"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="60dp"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="17dp" /> </androidx.constraintlayout.widget.ConstraintLayout>

item_recycler_view.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="wrap_content"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:id="@+id/tv_time"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="时间"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_weight="1"
android:text="姓名:" /> <TextView
android:id="@+id/tv_temp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="体温" /> </LinearLayout> </LinearLayout>
<Button
android:id="@+id/btn_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="编辑" /> </LinearLayout>

以上是全部源程序代码,具体如何定位,参考https://www.cnblogs.com/yuxuan-light-of-Taihu-Lake/p/14354416.html

那么呈现的画面就是:https://www.cnblogs.com/yuxuan-light-of-Taihu-Lake/p/14359500.html

整个项目project:

链接:https://pan.baidu.com/s/1PkH6Q5G4_3r0eVm8aG8F7Q
提取码:i8k7

遇到的问题:

1.定位的时候包名写错了

2.定位的时候手机没有开位置权限,导致一直没有定位成功

3.连接完数据库并存入数据库后,发现找不到数据库了

4.toast一直没有显示,结果发现忘记加.show()

5.radiogroup和radiobutton获取不到数据,现已解决

6.使用约束布局,在虚拟机上可以实现一些布局,发现到真机上排版乱了,原来是没有嵌入合成一个布局,导致不同屏幕的手机会呈现不同的布局

7.toast在手机上没有显示,原来是没有开权限

8.往数据库里面传时间的时候,传成当下的时间里了,导致出现了编辑的时候的bug

开发总结:

这个app算是在寒假自学开发的第一个app,懵懵懂懂,遇到了不少问题,也希望接下来能开发出更好的app。

体温登记app开发流程的更多相关文章

  1. 20个可以帮你简化iOS app开发流程的工具

    这里推荐20个可以帮你简化iOS app开发流程的工具.很多开发者都使用过这些工具,涉及原型和设计.编程.测试以及最后的营销,基本上涵盖了整个开发过程. 原型和设计 有了一个很好的创意后,你要做的不是 ...

  2. iOS开发之工具篇-20个可以帮你简化移动app开发流程的工具

    如果想进入移动app开发这个领域,你总能从别的开发者或者网上或者书上找到各种各样的方法和工具,对于新手来说,还没有摸清门路就已经陷入迷茫了.这里推荐20个可以帮你简化app开发流程的工具.很多开发者都 ...

  3. app开发流程有哪些

    app开发流程是需求方和供求方相互协调的过程,一般分为需求分析.功能设计.功能实现.项目测试.上线等几个步骤,下面我们就来一起看看ytkah团队进行app开发各个流程主要做哪些事情,让您对app开发设 ...

  4. 深度讲解智能硬件手机APP开发流程

    常州做APP开发公司紫竹云科技分析,智能硬件产品的软件开发,除了APP和后台之外还有一个固件端的开发,由于固件是要运行产品上的,不过此时的硬件也是刚开始进行研发,所以是无法提供硬件来运行固件的.因此在 ...

  5. android体温登记APP开发过程+问题汇总+源码

    源码上传至https://github.com/durtime/myproject下的temperature 实际效果:   开发过程 1.首先进行布局文件的编写,布局前台页面 2.布置两个按钮,一个 ...

  6. APP开发流程

    1.申请一个开发者账号: 2. App的idea形成: 3. App的主要功能设计: 4. App的大概界面构思和设计(使用流程设计): 5. 大功能模块代码编写: 6. 大概的界面模块编写: 7. ...

  7. iOS 直播类APP开发流程分解:

    1 . 音视频处理的一般流程: 数据采集→数据编码→数据传输(流媒体服务器) →解码数据→播放显示1.数据采集:摄像机及拾音器收集视频及音频数据,此时得到的为原始数据涉及技术或协议:摄像机:CCD.C ...

  8. App开发流程之源代码Git管理

    base项目已经可以编译运行了,只不过没有实际功能而已.继续完善base项目前,我们需要考虑一下代码管理的事情了. 不管是一个人开发还是一个团队开发,对源代码进行版本管理是必须的,任何人对代码的的任何 ...

  9. angular based app开发流程

    整理user story mock UI,生成满足上述user story的原型界面 根据上述UI,整理出data model(适用于后端和angular的数据模型) 后端CRUD开发,形成REST ...

随机推荐

  1. 关于SQL优化的辟谣

    列举一些关于 SQL 语句的谣言,避免一些生瓜蛋子面试的时候被另外一群生瓜蛋子的 SQL 优化宝典给坑了. 以下所有内容都是 SQL Server 中的,其他数据库只能参考和借鉴 一.全表扫描 全表扫 ...

  2. webpack--性能优化之打包构建速度和代码调试优化

    前言 本文来总结写webpack 在性能方面常见的优化方案. 正文 本文分别总结开发环境和生产环境中在打包构建速度和代码调试功能方面的优化方案,如下: 1.开发环境性能优化 (1)优化打包构建速度 a ...

  3. CMAK(Kafka Manager)安装

    CMAK 是管理Kafka集群的常用工具,之前的名字叫Kafka Manager.CMAK功能很强大,它可以管理多个Kafka集群,查看集群内部状态,如:topic.broker.consumer.p ...

  4. php jsonp接口

    //jsonp回调 $callback = isset($_GET['callback']) ? trim($_GET['callback']) : ''; //jsonp回调参数,必需 $cgc_k ...

  5. NOIP集训题目解析

    11.01 子段和 题目大意 给定一个长度为 \(n\) 的序列 \(a\) ,\(a_i=\{ -1,0,1 \}\) ,需要将 \(a\) 中的 \(0\) 变为 \(1\) 或 \(-1\) , ...

  6. C#+SQL Server的数据库管理系统常用的代码

    数据库管理系统 数据库管理系统(Database Management System)是一种操纵和管理数据库的大型软件,用于建立.使用和维护数据库,简称DBMS.它对数据库进行统一的管理和控制,以保证 ...

  7. java实现下载网络图片

    package com.gylhaut.picture;import java.io.*;import java.net.MalformedURLException;import java.net.U ...

  8. Android 12(S) 图形显示系统 - BufferQueue的工作流程(十)

    题外话 疫情隔离在家,周末还在努力学习的我  ..... 一.前言 上一篇文章中,有基本讲清楚Producer一端的处理逻辑,最后也留下了一个疑问: Consumer是什么时候来消费数据的?他是自己主 ...

  9. Spring Data ElasticSearch的使用

    1.什么是Spring Data Spring Data是一个用于简化数据库访问,并支持云服务的开源框架.其主要目标是使得对数据的访问变得方便快捷,并支持map-reduce框架和云计算数据服务. S ...

  10. # kubernetes节点不可调度

    查看node [root@k8s-masterb ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-mastera Ready maste ...