Search code examples
androidtoast

How to make toast (method not resloved)


Toast.makeText(this, "Note Deleted", Toast.LENGTH_SHORT).show();

why does it say that the method cannot be resloved? is it following a wrong format?


Solution

  • 1) Be sure that you have imported the Toast class

    2) If it's inside an Activity, your code will work.

    3) If it's inside a Fragment, you will need the context to show this:

    Toast.makeText(getActivity(),"Note Deleted",Toast.LENGTH_SHORT).show();