views:

42

answers:

2

Hi,

I want to show the softkeyboard, but it does not work. Here is my code: public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    myTextView myTextView = new myTextView(this);

    setContentView(myTextView);
}

public class myTextView extends EditText{

public boolean onTouchEvent(){

if(action == ACTION_DOWN){

super.onTouchEvent(event);

} }

When i touch the screen, the softkeyboard does not appear, but the alertDialog "edit text" appears, which appears on normal edittexts when you long touch them. This additional code in the onCreate has no affection: InputMethodManager input = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); input.showSoftInput(myTextView, 0);

Thanks for help, Fr4gg0r

A: 

Try this -

    myTextView.setOnFocusChangeListener(
            new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
                    if (hasFocus)
                              getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                }
            });
Soumya Simanta
A: 

I'm very sorry this very late answer.. So I tried your code with the following command: myTextView.requestFocus(); But the keyboard does not show up.

I have to correct my text: On the emulator, the keyboard does not show up, but on my Samsung Galaxy S, it does! :o

Fr4gg0r