Code example for DialogFragment

Methods: getActivity, getResources

0
 
	@Override 
	public Dialog onCreateDialog(Bundle savedInstanceState) {
 
		// Use the Builder class for convenient dialog construction 
		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
 
		builder.setTitle("Information")
				.setIcon(
						getResources().getDrawable(
								android.R.drawable.ic_dialog_info))
				.setMessage("Message saved as draft.")
				.setNeutralButton(android.R.string.ok, new OnClickListener() {
 
					@Override 
					public void onClick(DialogInterface arg0, int arg1) {
						// TODO Auto-generated method stub 
 
					} 
				});