views:

1107

answers:

4

I have added android:windowSoftInputMode="stateAlwaysVisible" to my Activity in AndroidManifest.xml and here's my layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <EditText android:id="@+id/EditText01" android:layout_width="wrap_content"
        android:layout_height="wrap_content"></EditText>
    <EditText android:id="@+id/EditText02" android:layout_width="wrap_content"
        android:layout_height="wrap_content"></EditText>
    <Button android:id="@+id/Button01" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="Send"></Button>
</LinearLayout>

alt text

When the Activity starts, the EditText is focused, but soft keyboard isn't displayed. If I click on the EditText, then I see the soft keyboard. Do I need to set aditional parameters to display soft keyboard when my Activity starts?

Thanks

+1  A: 

I believe its kind of bugged , read this : http://stackoverflow.com/questions/1509719/android-how-to-make-the-keypad-always-visible

Ravi Vyas
It works when I set "Keyboard Support" to false on the Emulator. Here's the key part from the discussion you referred: "Typically the emulator runs as a device that has a keyboard, in which case the system deliberately does not automatically show the IME because the user has easy access to a real keyboard."
Sarp Centel
This is interesting , I even tried InputMethodManager.showSoftInput() , the requested view gets focused but the KB still remains hidden/off. Infact I even setup a textview which wont get focus and setup a setOnFocusChangeListener to show the KB when the textview wont have focus but it did not work too . I am out of ideas :P
Ravi Vyas
A: 

Try adding this to the activities onCreate() method

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); 
Donal Rafferty
It didn't help, I'm already setting it via manifest anyway.
Sarp Centel
Have you tried not setting it at all? I had the opposite problem, I didn't want the soft keyboard to appear when the screen showed first but it semed to be the default setting that it did
Donal Rafferty
+2  A: 

solution 1 :

write following code inside onCreate() method of activity

InputMethodManager imm = (InputMethodManager) SearchActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);

if(imm != null){ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0); }

solution 2 :

create following method and call from onCreate()

private void showVirturalKeyboard(){

Timer timer = new Timer();
    timer.schedule(new TimerTask() {

         @Override
         public void run() {
              InputMethodManager m = (InputMethodManager) SearchActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);

              if(m != null){
                // m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
                m.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
              } 
         }

    }, 100);         

}

rakeshsoni
A: 

thanks Donal . this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
work well

Smith.dengta