0

I have an edittext with a field for movie name in my second activity. Sometimes the user will come into this activity and it will be empty, and the user should put in the name they want of the movie. In this case I want the virtual keyboard to automatically come up (which it does). However, sometimes the user enters this activity and the movie name is already in the edittext. In this case I want the virtual keyboard to not automatically come up. I have tried doing this, with an if condition that its not empty:

etMovieTitle.clearFocus();
linearLayout.requestFocus();

but it doesn't seem to work.

Thank you

1 Answers1

0

So you are going to want to take a look at this stackoverflow post and implement their method of hiding the soft/virtual keyboard.

You may have to check if the EditText has data, then request focus (assuming it doesn't already have focus when its open which it sounds like it does), and then implement the logic from that link!

There is a bunch of great information on that link and quite a bit of discusison.

Community
  • 1
  • 1
sargturner
  • 540
  • 2
  • 18