0

Take a look at this example:

public class TestEditSoftKbdActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    findViewById(R.id.editText1).setFocusable(false);
    findViewById(R.id.editText1).setClickable(false);
    findViewById(R.id.editText1).setEnabled(false);

    findViewById(R.id.editText1).setFocusable(true);
    findViewById(R.id.editText1).setClickable(true);
    findViewById(R.id.editText1).setEnabled(true);

    findViewById(R.id.editText1).invalidate();
    findViewById(R.id.editText1).requestLayout();
}

}

After this sequence of calls the edit text view would no longer pop up its soft input method upon being touched :(

Could someone explain what is going wrong here?

MikeD
  • 5,004
  • 1
  • 25
  • 39
kellogs
  • 2,837
  • 3
  • 38
  • 51
  • Why are you inflating a view 8 times? – Egor Aug 22 '11 at 10:46
  • 1
    It could be something simple - try setting enabled before focusable - it's entirely possible that setFocusable doesn't do anything on a disabled view. – Delyan Aug 22 '11 at 10:59
  • @Delyan - well reasoning, +1 for that alone. Only it did not help no matter how I have rearranged them – kellogs Aug 22 '11 at 18:04

1 Answers1

0

If you want to close soft keyboard for your text view follow this link. Here is a solution for you. But you need to define your own TextView to do that. He suggests using;

public class NoImeEditText extends EditText {
    public EditTextEx(Context context, AttributeSet attrs) { 
       super(context, attrs);     
    }      
    @Override      
    public boolean onCheckIsTextEditor() {   
        return false;     
    }        
} 

Hope it works.

Community
  • 1
  • 1
Sertalp B. Cay
  • 552
  • 7
  • 24