学习时间:2h
代码量100
package com.example.text_five;标签:Toast,2024.3,15,void,软件工程,new,import,android,public From: https://www.cnblogs.com/luoqingci/p/18093363
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.text_five.dao.UserDao;
import com.example.text_five.entity.User;
import java.sql.SQLException;
public class analysis extends AppCompatActivity {
EditText fenxi = null;
EditText buzu = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main6);
fenxi = findViewById(R.id.a2);
buzu = findViewById(R.id.a4);
}
public void 分析2(View view) {
String fenxi1 = fenxi.getText().toString();
String buzu1 = buzu.getText().toString();
User user = new User();
user.setAnalysis(fenxi1);
user.setBuzu(buzu1);
Intent intent = getIntent();
String account = intent.getStringExtra("account");
new Thread() {
@Override
public void run() {
UserDao userDao = new UserDao();
boolean flag = userDao.ana(user, account);
runOnUiThread(new Runnable() {
@Override
public void run() {
if (flag) {
Toast.makeText(analysis.this, "分析成功", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(analysis.this, "分析失败", Toast.LENGTH_SHORT).show();
}
}
});
}
}.start();
}
}