1

i have to detect if the soft-keyboard was opened. i have read some articles here on how to do it, one example is >this< there was another, maybe better one, but the two ar aiming at the same target, to check if the layout/View was forced to resize.

my problem here is, that that all is java code and i can't do anything with java code, because i don't know the Monodroid equivalents of the API, and some other small things...

Antoher thing i figured out is, that there is a InputMethodService.OnWindowShown() method/Event, and a identifier wheter the keyboard is shown or not.

var inputManager = (InputMethodService)GetSystemService(InputMethodService);
inputManager.OnWindowShown();
bool bla = inputManager.IsInputViewShown;

is there a way to identify if the keyboard was opened, with these lines, or do i have to do the resize thing? and if the resize is the only thing, how dos it work in Mono for Android?

Community
  • 1
  • 1
EaranMaleasi
  • 825
  • 1
  • 12
  • 30

2 Answers2

3

try this:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

    if (imm.isAcceptingText()) {
        writeToLog("Software Keyboard was shown");
    } else {
        writeToLog("Software Keyboard was not shown");
    }
jlopez
  • 6,287
  • 2
  • 51
  • 90
  • got one error, the getActivity() is not known... do i have to import something special for it? – EaranMaleasi Jan 25 '13 at 09:06
  • so... where can i set an id to the root view of my activity and what is the root view at all? as you can see i'm not very familiar with android, and i have to learn it now with mono for android, somitimes beeing even harder to learn. to figure out that a certain part of the api is namend different in monodroid and eventually works on another way... – EaranMaleasi Jan 31 '13 at 09:45
1

You can't detect if soft keyboard is shown or not,but you can indirectly know that a soft key board is shown by knowing that the view of your activity is resized.
This 2 lines hide the soft keyboard..

var input = (InputMethodManager)GetSystemService(InputMethodService);
input.HideSoftInputFromWindow(editText1.WindowToken, HideSoftInputFlags.None);

Also can see..

ridoy
  • 6,158
  • 2
  • 27
  • 60
  • i don't want to hide the keyboard, i want to know if the keyboard was opened so i can hide a tabWidget, taking way to much space on the screen. – EaranMaleasi Jan 31 '13 at 06:57