public class MainActivity2 extends AppCompatActivity {
private Button goalAnalysisButton;
private Button dailyCheckInButton;
private Button statisticsButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
goalAnalysisButton = findViewById(R.id.GoalAnalysisButton);
dailyCheckInButton = findViewById(R.id.DailyCheckInButton);
statisticsButton = findViewById(R.id.StatisticsButton);
// 目标与分析按钮点击事件
goalAnalysisButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity2.this, GoalAnalysis.class);
startActivity(intent);
}
});
// 每日打卡按钮点击事件
dailyCheckInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity2.this, DailyCheckIn.class);
startActivity(intent);
}
});
}
// 处理统计与分析按钮点击事件
public void queryStatisticsData(View view) {
new Thread() {
@Override
public void run() {
// 在后台线程中执行查询统计数据的操作
// 获取当前登录用户的 studentId
String studentId = StudentDao.getCurrentLoggedInUserId();
// 获取学生对象
StudentDao studentDao = new StudentDao();
Student student = studentDao.findStudent(studentId);
if (student != null) {
// 获取 setGoal、setRecord 和完成度百分比
int setGoal = student.getSetGoal();
int setRecord = student.getSetRecord();
double completionPercentage = PlanningDao.calculateCompletionPercentage(studentId);
// 创建一个列表存储数据
ArrayList<StatisticData> statisticDataList = new ArrayList<>();
statisticDataList.add(new StatisticData(studentId, setGoal, setRecord, completionPercentage));
// 将数据传递给 Statistics 类(com.example.demo3 包下)
Intent intent = new Intent(MainActivity2.this, Statistics.class);
intent.putParcelableArrayListExtra("statisticDataList", statisticDataList);
startActivity(intent);
}
}
}.start();
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统