-1

I have a edit text view and button right side to it. When I click the button edittext has to get focus and keyboard has to appear. I programmitically tried following.

name_text = (EditText)findViewById(R.id.name_text);
        name_edit = (ImageView)findViewById(R.id.name_edit_icon);
        name_text.setFocusable(false);
        name_edit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                name_text.setFocusable(true);
                //name_text.setEnabled(true);    
            }
        });

I tried all possiblities, none is worked for me. Please help me. Thanks.

wmk
  • 4,598
  • 1
  • 20
  • 37
Voora Tarun
  • 1,266
  • 1
  • 20
  • 38
  • 1
    Use `requestFocus()`. https://stackoverflow.com/questions/6794234/change-focus-to-edittext-android – Jameson Nov 09 '15 at 08:03

1 Answers1

3

Write this code inside the click event to TOGGLE the keyboard:

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
Anshuman Borah
  • 538
  • 2
  • 10