Code example for DialogFragment

Methods: getActivity, getArguments, getTag

0
    return dialogFragment;
  } 
  //KEY_ROWID + " != " + getArguments().getLong("fromAccountId") 
  @Override 
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();
    Bundle bundle = getArguments();
    String column = bundle.getString("column");
    Cursor c = ((SelectFromCursorDialogListener) ctx).getCursor(bundle.getInt("cursorId"),getTag());
    mAdapter = new SimpleCursorAdapter(ctx, android.R.layout.select_dialog_singlechoice,
        c, new String[]{column}, new int[]{android.R.id.text1},0);
    return new AlertDialog.Builder(ctx)
      .setTitle(bundle.getString("dialogTitle"))
      .setAdapter(mAdapter,this)
      .create();
  } 
  @Override 
  public void onClick(DialogInterface dialog, int which) {
    SelectFromCursorDialogListener activity = (SelectFromCursorDialogListener) getActivity();
    Bundle args = getArguments();
    args.putLong("result", ((AlertDialog) dialog).getListView().getItemIdAtPosition(which));