Создать пользовательский тост.
private Toast myToast = nuul; // Create class Level Object to
Добавить этот код в методе
String message = "Your Message";
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast,
the (ViewGroup) findViewById(R.id.custom_toast_container));
TextView text = (TextView) layout.findViewById(R.id.custom_toast_text);
text.setText(Message);
myToast = new Toast(getApplicationContext());
myToast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
myToast.setGravity(Gravity.CENTER_HORIZONTAL, 0, 0);
myToast.setDuration(Toast.LENGTH_LONG);
myToast.setView(layout);
myToast.show();
custom_toast.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_toast_container"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="8dp"
android:background="#80000000">
<TextView
android:id="@+id/custom_toast_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:enabled="true"
android:textSize="16dp"
/>
</LinearLayout>
Отклонить тост, если он не равен нулю
if (myToast != null)
myToast.cancel(); // Dismiss the toast