Created
January 15, 2015 22:21
-
-
Save marchold/abdee8bd674ffa3927e4 to your computer and use it in GitHub Desktop.
A simple dialog box for android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.AlertDialog; | |
import android.app.Dialog; | |
import android.app.DialogFragment; | |
import android.app.FragmentManager; | |
import android.content.DialogInterface; | |
import android.os.Bundle; | |
/** | |
* Generic message dialog | |
*/ | |
public class MessageDialog extends DialogFragment { | |
public MessageDialog() { | |
} | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
return new AlertDialog.Builder(getActivity()) | |
.setMessage(getArguments().getString("message")) | |
.setTitle(getArguments().getString("title")) | |
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int whichButton) { | |
} | |
}) | |
.create(); | |
} | |
public static final void show(FragmentManager fragmentManager, String title, String message){ | |
if (fragmentManager==null) return; | |
MessageDialog d = new MessageDialog(); | |
Bundle bundle = new Bundle(); | |
bundle.putString("title",title); | |
bundle.putString("message",message); | |
d.setArguments(bundle); | |
d.show(fragmentManager, "MessageDialog"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment