2
I have this dialog in my application
public void alertaLocalizar(View v) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.alerta_comum, null);
Dialog localizar = new Dialog(this);
localizar.requestWindowFeature(Window.FEATURE_NO_TITLE);
localizar.setContentView(view);
localizar.show();
}
}
And I wanted to force open the keyboard as soon as it was opened, how can I do that?
And taking advantage of the question, I would like to know how to use the keyboard OK button to have the same effect as the Alert OK button and not close the keyboard.
I’m sorry to be unaware, but where in the code would I have to enter?
– crnmn
Thank you @Falion, I got exactly what I wanted, but I just got a little problem, I checked in the documentation of
ImputMethodManager
and I couldn’t find. I put on the cancel button, to hide the keyboard, this usually happens if the keyboard is open, but when the user clicks on the Back of the device, the keyboard disappears, and clicking Cancel, it reappears. Can you make sure that doesn’t happen? Or better yet, stop the keyboard from disappearing, unless you click cancel?– crnmn
You’re using the Keyevent ? Because if yes, you can put an if/case that will check that only if clicked on Cancel,it will make the keyboard disappear.
– Falion
No, buddy. I’m not using Keyevent. What I did was put on the alert the IMM to force the keyboard to appear as shown the alert, and disappear when clicked Cancel on the alert, what works normal. It turns out that when the keyboard is already closed (the user clicked back and the keyboard hid) and the user clicks Cancel, instead of remaining hidden, it reappears. But I believe it is a Bug since in tests, times reappeared, others remained hidden. So I decided not to use the IMM in this case, since it will not disturb the user in anything. Thank you for your attention!
– crnmn
If you have more questions then,can ask friend,because this site is to help those who need. I advise you to always test your codes repeatedly, to be sure where the problem comes from.If I helped you, put my answer as "Useful answer". I’m glad my answer helped you.
– Falion
Thanks, I’m still familiarizing myself with the site, I did this and I will do the next ones too. Sometimes I have some questions that may be quite simple, but I am a web programmer, not Android, hence the need to develop this app and I’m venturing. Thank you for your attention.
– crnmn