package com.example.test_one;标签:5.2,void,station,Override,import,android,public From: https://www.cnblogs.com/kongxiangzeng/p/18246538
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.example.test_one.dao.UserDao;
import com.example.test_one.entity.User;
public class station extends AppCompatActivity {
private EditText station;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_station);
station=findViewById(R.id.r2);
}
public void 站名2(View view) {
String station2Text = station.getText().toString(); // 使用不同的变量名
User user = new User();
user.setStarting_Station(station2Text); // 使用不同的变量名
Thread thread = new Thread() {
@Override
public void run() {
final String result2 = UserDao.station(user);
// 在主线程更新UI
runOnUiThread(new Runnable() {
@Override
public void run() {
TextView resultTextView = findViewById(R.id.r4);
resultTextView.setText(result2);
}
});
}
};
// 启动线程
thread.start();
}
}