package net.cbaines.suma; import android.view.View; import android.widget.TextView; import android.widget.Toast; import com.j256.ormlite.android.apptools.OrmLiteBaseActivity; public class ToastHelperActivity extends OrmLiteBaseActivity { private Toast toast; private View toastView; private TextView toastMessageTextView; private TextView toastSubMessageTextView; void makeToast(String message, int length) { makeToast(message, null, length); } void makeToast(String message, String subMessage, int length) { if (toastView == null) { toastView = (View) getLayoutInflater().inflate(R.layout.toast_view, null); } if (toast == null) { toast = new Toast(this); } toastMessageTextView = (TextView) toastView.findViewById(R.id.toastViewText); toastMessageTextView.setText(message); toastSubMessageTextView = (TextView) toastView.findViewById(R.id.toastViewSubMessage); if (subMessage != null) { toastSubMessageTextView.setText(subMessage); toastSubMessageTextView.setVisibility(View.VISIBLE); } else { toastSubMessageTextView.setText(""); toastSubMessageTextView.setVisibility(View.GONE); } toast.setDuration(length); toast.setView(toastView); toast.show(); } }