I made a custom alertDialog and in it I have put an EditText, but the problem is the keyboard won't show when I click on the EditText to write an input!
Here's my alert dialog class:
public class EditTaskDialog extends AlertDialog {
Activity mParent;
public EditTaskDialog(Context context, Activity parent) {
super(context);
mParent = parent;
}
@BindView(R.id.btn_edit_edti_task_dialog)
Button btn_edit_edti_task_dialog;
@BindView(R.id.tv_time_edit_task_dialog)
TextView tv_time_edit_task_dialog;
@BindView(R.id.ll_time_edit_task_dialog)
LinearLayout ll_time_edit_task_dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//the layout that have the edit text view
setContentView(R.layout.edit_task_dialog);
ButterKnife.bind(this);
final DatePickerDialog.OnDateSetListener x = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
tv_time_edit_task_dialog.setText(dayOfMonth+ "/" + (month+1) +"/"+ year);
}
};
ll_time_edit_task_dialog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new DatePickerDialog(
mParent,
x,
Calendar.getInstance().get(Calendar.YEAR),
Calendar.getInstance().get(Calendar.MONTH),
Calendar.getInstance().get(Calendar.DAY_OF_MONTH)
).show();
}
});
}
}
Please notice that I can't use getSystemService() because it's connected to the activity that started the alertDialog so when I use it like this
InputMethodManager imm = (InputMethodManager) mParent.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
the keyboard shows behind the alert dialog and in front of the starting activity