2015年7月26日 星期日

[Android] Toast

We have two method to use Toast 我們有兩種方式來顯示Toast

1.ToastActivity.this depends on this class name
 Toast toast = Toast.makeText(ToastActivity.this,"Hello world!", Toast.LENGTH_LONG);
 toast.show();
2.getApplicationContext()to get Current Context
 Context context1 = getApplication();
 Toast.makeText(context2, "Hello world!", Toast.LENGTH_LONG).show();

沒有留言:

張貼留言