tags:

views:

216

answers:

0

Hi,

I need to pop a software keyboard and listen by the TextWatcher interface. I don't want any widget do be displayed, I need to do the thinks by myself. I haven't find how to do that without creating an EditText widget instance. My idea has been to create EditText widget and keep it hidden.

EditText e = (EditText)((Activity)vv.getContext()).findViewById(R.id.native_input);
AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams (100,100,10,10);
e.setVisibility(INVISIBLE);
e.addTextChangedListener(new MyTextWatcher());

This does not work. TextWatcher is not called. So, it seems the widget must be visible. To keep it hidden I decided to set its size to be (0,0,0,0)

EditText e = (EditText)((Activity)vv.getContext()).findViewById(R.id.native_input);
AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams (0,0,0,0);
e.setVisibility(VISIBLE);
e.addTextChangedListener(new MyTextWatcher());

This "works" but it has a problem. "Del" key and numbers do not work. Hmmm, strange. WTF?

EditText e = (EditText)((Activity)vv.getContext()).findViewById(R.id.native_input);
AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams (1,0,0,0);
e.setVisibility(VISIBLE);
e.addTextChangedListener(new MyTextWatcher());

and this seems to be ok.

Well, I don't think, this is a correct solution. Any idea how to do this by a clear way? Also, why numbers do not work when "...LayoutParams (0,0,0,0);"?

Thanks,

Ondrej