package com.example.test_one;标签:5.1,station1,void,station,user,import,public From: https://www.cnblogs.com/kongxiangzeng/p/18246536
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import com.example.test_one.dao.UserDao;
import com.example.test_one.entity.User;
public class start_end extends AppCompatActivity {
private EditText s_station;
private EditText e_station;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start_end);
s_station=findViewById(R.id.t2);
e_station=findViewById(R.id.t3);
}
// public void 起终2(View view){
//
// String s_station1 = s_station.getText().toString();
// String e_station1 = e_station.getText().toString();
//
// User user = new User();
//
// user.setStarting_Station(s_station1);
// user.setTerminus_Station(e_station1);
//
// new Thread(){
// @Override
// public void run(){
//
// final String result3 = UserDao.shortest(user);
//
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// TextView resultTextView = findViewById(R.id.t5);
// resultTextView.setText(result3);
// }
// });
//
// }
// }.start();
// }
public void 起终2(View view) {
String s_station1 = s_station.getText().toString();
String e_station1 = e_station.getText().toString();
User user=new User();
user.setStarting_Station(s_station1);
user.setTerminus_Station(e_station1);
try {
Thread thread = new Thread() {
@Override
public void run() {
UserDao.shortest(user);
}
};
thread.start(); // 启动线程
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}