我想做一个 toast ,但 toast 没有打印
Request r = new Request.Builder().url(url).build();
client.newCall(r).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
Toast.makeText(Login.this, "password wrong", Toast.LENGTH_LONG).show();
}
最佳答案
Android 中的每个 UI 更新都必须在 UI 线程中执行:
在onFailure中运行以下代码
Login.this.runOnUiThread(new Runnable() {
@Override
public void run() { Toast.makeText(Login.this, "password wrong", Toast.LENGTH_LONG).show();
}
});
关于java - 在Request Android Studio中做一个Toast,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60970096/