Android Application Development Tutorial – 93 – Hiding the Keyboard



Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Related Posts

20 Comments

  1. Hi there. Do you have tutorials or guide on creating a custom keyboard? I would to create one that only consist of selected characters.. Hope to hear from you. Thanks! 🙂

  2. Just to have the GO key on Keyboard 🙂

    1 – in your xml file under your url edit text tag, put this attribute android:imeOptions="actionGo"

    2 – url.setSingleLine(true);

    3 – url.setOnKeyListener(this);

    4 – @Override
    public boolean onKey(View v, int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub

    if(URLUtil.isValidUrl(url.getText().toString())) {
    if(keyCode == KeyEvent.KEYCODE_ENTER) {

    onClick(go);
    }
    }
    return false;
    }

  3. this works for me :
    ourBrow.requestFocus(View.FOCUS_DOWN);
    ourBrow.setOnTouchListener(new View.OnTouchListener(){ @Override public boolean onTouch(View v, MotionEvent event){ switch (event.getAction()){ case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()){
    v.requestFocus(); } break; } } });

  4. if you set your AVD's config settings hw.keyboard=yes then the keyboard won't show up at all in v20. Now how do I make it appear anyway? I've tried adding this:

    @Override
    public void onFocusChange(View v, boolean hasFocus) {
    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    if (v.hasFocus()) {
    imm.showSoftInput(v, 0);
    } else {
    imm.hideSoftInputFromWindow(url.getWindowToken(), 0);
    }

    }

    but to no avail.

Leave a Reply

Your email address will not be published.

© 2022 Code As Pro - Theme by WPEnjoy · Powered by WordPress