I have an edittext in a fragment in a static class which extends DialogFragment. I need get user input from edittext inside the fragment. I tried instantiating container activity and passing the value but it doesn't work because I need to make it final, I think. Please see the code below of the static class:
public class DetailDaily extends BaseActivity implements GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
...................
..................
String name;
........
public static class DialogCreater extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final DetailDaily dd = new DetailDaily();
int title = getArguments().getInt("Title");
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Set the dialog title
switch (title) {
case 1:
....................................
case 2:
final LayoutInflater inflater = getActivity().getLayoutInflater();
final View mView = inflater.inflate(R.layout.edit_dialog, null);
builder.setView(mView)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
EditText userInput = (EditText) mView.findViewById(R.id.dialogEdit);
dd.name = userInput.toString();
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
break;
}
return builder.create();
}
}
How to read the userInput out of static class?