今日总结

2021年2月1日:

今日看了网上的体温开发视频,做了一部分,包括填写姓名,日期和体温,以下是我的代码:

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout tools:context="com.example.myapplication.MainActivity"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="30dp"
android:text="信1905-2学生体温登记表"
android:textColor="@color/colorPrimaryDark"
android:textSize="35dp" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="15dp"
android:text="姓名:"
android:textSize="30dp"
android:textColor="@color/black"
/>
<EditText
android:layout_width="270dp"
android:layout_height="70dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="10dp"
android:hint="请输入你的姓名" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="15dp"
android:text="体温:"
android:textSize="30dp"
android:textColor="@color/black"
/>
<EditText
android:layout_width="270dp"
android:layout_height="70dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="10dp"
android:hint="请输入今日体温:如(36.5/36.9)" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="15dp"
android:text="填报日期:"
android:textSize="30dp"
android:textColor="@color/black"
/>
<EditText
android:id="@+id/date"
android:layout_width="210dp"
android:layout_height="70dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="10dp"
android:hint="请输入今日日期" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="15dp"
android:text="你的位置:"
android:textSize="30dp"
android:textColor="@color/black"
/>
<EditText
android:id="@+id/address"
android:layout_width="210dp"
android:layout_height="70dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="10dp"
android:hint="请输入你的地理位置" />
</LinearLayout>
<LinearLayout
android:layout_width="350dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="0dp"
android:orientation="horizontal">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape"
android:text="提交"
android:textColor="#FFFFFF"
android:textSize="20dp"/>
</LinearLayout>
</LinearLayout

package com.example.myapplication;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
private long exitTime = 0; //退出时间变量值
private EditText text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text=(EditText)findViewById(R.id.date);
text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v){
startActivityForResult(new Intent(MainActivity.this, Tiwenapp.class),0x11);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode,resultCode,data);
if(requestCode==0x11 && resultCode==0x11){
Bundle bundle=data.getExtras();
String date=bundle.getString("data");
text.setText(date);
}
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
exit();
return true; //拦截返回键
}
return super.onKeyDown(keyCode, event);
}
public void exit() {
if ((System.currentTimeMillis() - exitTime) > 2000) { //计算按键时间差是否大于两秒
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
exitTime = System.currentTimeMillis();
} else {
finish();
System.exit(0); //销毁强制退出
}
}
}

 

 明天开发地点。

原文地址:https://www.cnblogs.com/yitiaokuailedexiaojingyu/p/14358578.html