In my app, I construct a calendar widget for my activity, when I scroll it to previous or next month, I let it make a toast and show it.
The question is, the toast n
public static Toast sToast=null;
// create Toast object;
public void showToast(String msg)
{
//here is checking whether toast object is null or not;if not null gonna cancel the toast that is showing in phone window and make it null;
if(sToast!=null)
{
sToast.cancel;
sToast=null;
}
//if toast object is null,gonna create new instance and make it shown on phone window.
if(sToast==null)
{
sToast=Toast.makeText(currentActivity.this,msg,Duration);
sToast.setGravity();
sToast.show();
}
}