Cannot resolve maketext() method of Toast

后端 未结 18 2385
旧时难觅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:18

    I have faced similar problem in android studio, I resolve this issue by using getActivity() instead of this in the fragment

    Toast.makeText(getActivity(), "Your Text", Toast.LENGTH_SHORT).show();
    

提交回复
热议问题