If you think the Android project my-wallpaper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.koonen.utils;
//www.java2s.comimport android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.koonen.photostream.R;
/**
*
* @author glick
*
*/publicclass DialogUtils {
publicstaticinterface ClickHandler {
publicvoid handle();
}
publicstatic Dialog createInfoDialog(Context context, int messageId,
final ClickHandler okHandler, final ClickHandler cancelHandler) {
LinearLayout layout = new LinearLayout(context);
LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(layoutParams);
layout.setPadding(5, 0, 0, 0);
TextView view = new TextView(context);
view.setText(messageId);
view.setLayoutParams(layoutParams);
layout.addView(view);
final AlertDialog dialog = new AlertDialog.Builder(context).setTitle(
R.string.dialog_name_info).setView(layout).create();
dialog.setButton(context.getResources().getString(
R.string.ok_button_label),
new DialogInterface.OnClickListener() {
@Override
publicvoid onClick(DialogInterface arg0, int arg1) {
if (okHandler != null) {
okHandler.handle();
}
dialog.dismiss();
}
});
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
publicvoid onCancel(DialogInterface arg0) {
if (cancelHandler != null) {
cancelHandler.handle();
}
}
});
dialog.getWindow().setGravity(Gravity.CENTER);
return dialog;
}
publicstaticvoid showInfoDialog(Context context, int messageId,
final ClickHandler okHandler, final ClickHandler cancelHandler) {
createInfoDialog(context, messageId, okHandler, cancelHandler).show();
}
}