0

I disabled softkeypad in my application because I have my own custom keypad. But the problem is when I clicked on the edittexts in order to enter data through my custom keypad ,that edittexts are not getting highlighted at all. Even cursor is not visible inside that respective clicked edittext. Why there are always side effects while disabling soft keypad? I tried all the suggestions that are there in the sources including stackoverflow, but nothing worked. Can I get the perfect solution to get the edittext highlighted when clicked?

Kanth
  • 6,681
  • 3
  • 29
  • 41

2 Answers2

1

you need to call textView.requestFocus() when clicked this way your editText can be highlight

dont forget also to add in your XML File this attribute android:focusableInTouchMode="true" to your EditText

Tomer Mor
  • 7,998
  • 5
  • 29
  • 43
  • Thanks for your response. But this didn't work either. I have created edittexts dynamically, so when I added setFocusableInTouchMode(true), the soft keypad is popping up. And when I added requestFocus, there is nothing difference either. – Kanth Sep 04 '12 at 03:28
1

I don't know why those side effects occur, but in this post there is a workaround how disable the keyboard and still have the cursor. That worked for me except that I also needed to request focus, so it's:

    //disable keypad
    et.setOnTouchListener(new OnTouchListener(){
        @Override
        public boolean onTouch(View v, MotionEvent event) {

            int inType = et.getInputType(); // backup the input type
            et.setInputType(InputType.TYPE_NULL); // disable soft input
            et.onTouchEvent(event); // call native handler
            et.setInputType(inType); // restore input type
            et.requestFocus(); // request focus
            return  true; // consume touch even
        }
        });
Community
  • 1
  • 1
Georg
  • 960
  • 2
  • 7
  • 22
  • Thanks for your time. But it didn't work either in my case. Really there are lot of questions which are unanswered or the answers for some questions are vague like softkeypad, missing R.java file etc., – Kanth Sep 04 '12 at 07:08
  • What was it that didn't work? Did the keyboard show up or did you not get a cursor? – Georg Sep 04 '12 at 09:49