如何在asyntask里面的android中创建吐司

时间:2015-12-23 10:13:05

标签: android android-asynctask

我这样做了:

doInBackground(String... prams){
    Toast.makeText(getApplicationContext(),
                            "Server too busy. Please try after sometime.",
                            Toast.LENGTH_LONG).show();}

获取错误。请帮忙。

2 个答案:

答案 0 :(得分:1)

您无法在doInBackground中更新UI。请执行此操作以显示吐司

getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                Toast.makeText(getApplicationContext(),
                        "Server too busy. Please try after sometime.",
                        Toast.LENGTH_LONG).show();

            }
        });

它将解决您的问题

答案 1 :(得分:1)

您无法在

中显示祝酒词
doInBackground(String... prams){}

enter image description here