5.2

package com.example.test_one;

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();
}





}
posted @ 2024-06-13 18:49  kxzzow  阅读(7)  评论(0)    收藏  举报