Help Dialog Creator
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
class HelpDialogCreator {
private static final String SHOWN_ALREADY = "SHOWN_ALREADY";
public static void helpDialog(Activity activity, String title,
String helpContent, String backButtonTxt, boolean showOnlyOnce) {
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences(activity);
boolean shownAlready = sp.getBoolean(SHOWN_ALREADY, false);
if (!shownAlready || !showOnlyOnce) {
new AlertDialog.Builder(activity)
.setTitle(title)
.setMessage(helpContent)
.setPositiveButton(backButtonTxt,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialoginterface, int i) {
}
}).show();
Editor edit = sp.edit();
edit.putBoolean(SHOWN_ALREADY, true);
edit.commit();
}
}
}
Related examples in the same category