【发布时间】:2023-03-08 11:56:01
【问题描述】:
我想先执行带有文本“tex2”的 Toast,然后执行带有文本“text1”的 Toast,但是
在我的代码中,当我执行下面的代码(我的意思是具有相同结构的不同代码)时,它会以相反的顺序打印。
(说我想等待响应然后执行下一步)
class A
{
public int onStartCommand(Intent intent, int flags, int startId)
{
getdatafromnet();
Toast.makeText(getApplicationContext(), "text1", Toast.LENGTH_LONG).show();
//..................code
}
void getdatafromnet()
{
//volley server call
stringRequest=new StringRequest(Request.Method.GET, url2,
new Response.Listener<String>()
{
@Override
public void onResponse(String response)
{
Toast.makeText(getApplicationContext(), "text2",Toast.LENGTH_LONG).show();
}
});
//....follwing volley parameters and calls
}
}
【问题讨论】:
-
您知道 toeas toes 不会对您的代码提供任何响应吗?它只是向用户显示发生了一些事情。开火并忘记
-
还有另一个代码而不是Toast,我以Toast为例来清除我想要的执行流程
标签: java android android-volley