学习时间2h
代码量100
package com.example.text_five;标签:account,2024.3,19,软件工程,intent,import,Intent,Calendar,View From: https://www.cnblogs.com/luoqingci/p/18093366
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Calendar;
public class Main extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
}
public void 打卡记录(View view) {
String account = getIntent().getStringExtra("account");
Intent intent = new Intent(this, View_records.class);
intent.putExtra("account", account);
startActivity(intent);
}
public void 打卡(View view) {
String account = getIntent().getStringExtra("account");
Intent intent = new Intent(this, Clock_in.class);
intent.putExtra("account", account);
startActivity(intent);
}
public void 分析(View view) {
Calendar calendar = Calendar.getInstance();
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
// 判断当前系统日期是否为周五(Calendar.FRIDAY 对应值为6)
if (dayOfWeek == Calendar.FRIDAY) {
String account = getIntent().getStringExtra("account");
Intent intent = new Intent(this, analysis.class);
intent.putExtra("account", account);
startActivity(intent);
} else {
// 如果不是周五,给出提示或者执行其他操作
Toast.makeText(this, "今天不是周五,无法进行下列操作", Toast.LENGTH_SHORT).show();
}
}
public void 目标(View view) {
Calendar calendar = Calendar.getInstance();
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
// 判断当前系统日期是否为周一(Calendar.SUNDAY 对应值为1,Calendar.MONDAY 对应值为2)
if (dayOfWeek == Calendar.MONDAY) {
String account = getIntent().getStringExtra("account");
Intent intent = new Intent(this, target.class);
intent.putExtra("account", account);
startActivity(intent);
} else {
// 如果不是周一,给出提示或者执行其他操作
Toast.makeText(this, "今天不是周一,无法进行下列操作", Toast.LENGTH_SHORT).show();
}
}
}