Cannot resolve maketext() method of Toast

后端 未结 18 2398
旧时难觅i
旧时难觅i 2021-02-07 02:02

I am getting error while creating a Toast

Toast toast = Toast.makeText(this, text, duration);

I am getting cannot resolve ma

18条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-07 02:20

    Have you imported the toast widget?

    import android.widget.Toast;
    

    You can also call show() in the same line if you want to output it straight away:

    Toast toast = Toast.makeText(context, text, duration).show();
    

    Hope that helps.

提交回复
热议问题