Context context = getApplicationContext(); CharSequence text = "Hello toast!"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show();
Tutorial_Dialog_ToastActivity/java
package com.powenko.Tutorial_Dialog_Toast; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.widget.Toast; public class Tutorial_Dialog_ToastActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Context context = getApplicationContext(); CharSequence text = "Hello toast! PowenKo.com"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } }
reference:
http://developer.android.com/guide/topics/ui/notifiers/toasts.html
Toast.makeText(getApplicationContext(),"資料更新中", Toast.LENGTH_SHORT).show();