I'm new here, I apologize if this is a lousy question to ask. But I'd like to know the difference between these two versions of code.
1) This one will allow the Toast to change instantaneously.
public Toast toast;
public void showToast(String text)
{
if (toast != null)
{
toast.cancel();
}
toast = Toast.makeText(getApplicationContext(), text, Toast.LENGTH_LONG);
toast.show();
}
2) This one doesn't change instantaneously.
public Toast toast;
public void showToast(String text)
{
if (toast != null)
{
toast.cancel();
}
toast.makeText(getApplicationContext(), text, Toast.LENGTH_LONG).show();
}
Why does it have to be Toast class.makeText and not toastObject.makeText? Or is it because show() method has to be separate? I'm still new to Java and Android, can someone explain what is the fundamental difference between the two? Thanks in advance.