Friday, August 9, 2013

[android-developers] Re: Focus problem with Option menu

Any ideas guys?

Thanks

Il giorno giovedì 8 agosto 2013 11:50:25 UTC+2, drenda ha scritto:
Hi,
I've a problem with Option menu and focus.
I've a simple View in which I've some data come from remote service. I've to display an icon of the option menu only sometimes when remote object has some characteristics.

So I do this:

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        return true;
    }

    @Override    public boolean onPrepareOptionsMenu(Menu menu) {


        if (corsa != null && corsa.getDataPartenzaEffettiva() == null) {
            menu.clear();
            getMenuInflater().inflate(R.menu.dettaglio_corsa, menu);
        }
        return true;
    }

The first time I create an empty menu and then when I receive remote data (asyncCall) I call   invalidateOptionsMenu(); so I display the option menu icon. All works fine but in this view I open programatically the keyboard:

 InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        if (inputMethodManager != null) {
            inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        }

the problem is that every time I press a key on the keyboard the icon of Option menu focus, and when I press "enter" the option menu is clickked. I don't want this, why the option menu is focused every time I press a key?

Thanks


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment