I\'m trying to make a Fragment
to show a Dialog
using DialogFragment API.
My dialog only has an EditText
view and I want to pa
you can use callbacks. just implement a "done" button or something like that in your dialogfragment.
so in your dialogfragment do something like this:
protected OnDialogClickedListener callback = null;
public interface OnDialogClickedListener {
public abstract void onDialogClicked(int position);
}
public void setOnDialogClickedListener(OnDialogClickedListener l){
callback = l;
}
button.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
callback.onDialogClicked(position);
dismiss();
}
});
in your activity do something like this:
final YourFragment f = YourFragment .newInstance(0);
f.show(ft, "YourFragment ");
f.setOnDialogClickedListener(new OnDialogClickedListener() {
@Override
public void onDialogClicked(int position) {
updateText(position);
f.dismiss();
}
});
You can use the setTargetFragment and getTargetFragment methods of Fragment
. You can set your Fragment
as the target of the DialogFragment
and then retrieve a reference to it from within the DialogFragment
.