Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Soft keyboard doesn't appear

I'm testing my app on android 4.0.4 Samsung galaxy duos, the problem is if I set:

android:textIsSelectable="true"

the keyboard doesn't appear, though it appears on the emulator. Any suggestions?

Here is how my EditBox looks like

<EditText 

        android:focusable="true"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"        
        android:inputType="textVisiblePassword|textCapWords|textMultiLine"
        android:textIsSelectable="true"
        android:gravity="top|left"
        android:minLines="6"
        android:maxLines="10"
        android:minHeight="140dp"
        android:hint="@string/message"
        />
      <requestFocus />
like image 468
Dakait Avatar asked Dec 11 '13 07:12

Dakait


People also ask

How do I get the Android keyboard to appear?

To enable your latest Android keyboard, scroll to the bottom and hit the System entry. Then, click Languages & input. Pick Virtual keyboard on the following page. You will find a list of all the existing keyboards on your smartphone here.

How do I show keyboard in iOS emulator?

How do I enable the keyboard for simulator? Click the simulator menu Hardware —> Keyboard, check the Connect Hardware Keyboard sub-menu, and then uncheck it at once. Now the keyboard will be prompted automatically when you click the text field or text view UI component in the iOS simulator.

What is soft keyboard in Android?

The Android system shows an on-screen keyboard—known as a soft input method—when a text field in your UI receives focus.


2 Answers

Add a requestfocus. In xml:

<EditText>
    <requestFocus />
</EditText>  

Programmatically

edittext.requestFocus();

To "force" the SoftKeyboard to appear, you can do it dynamically:

InputMethodManager mImm = (InputMethodManager) 
                        getSystemService(Context.INPUT_METHOD_SERVICE);  
mImm.showSoftInput(SearchEdit, InputMethodManager.SHOW_IMPLICIT);  

Set onFocusChangeListener to appear your keyboard:

edittext.setFocusable(true);  
edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() {  
   @Override  
   public void onFocusChange(View v, boolean hasFocus) {  
       if (hasFocus)   
           mImm.showSoftInput(SearchEdit, InputMethodManager.SHOW_IMPLICIT);  
       else  
           mImm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);  
   } 
});  

See InputMethodManager Documentation for more information.
See also these answers to forcing the Keyboard to appear: Forcing the Soft Keyboard open

like image 110
Blo Avatar answered Oct 16 '22 08:10

Blo


You need to put requestFocus inside EditText element:

<EditText 

        android:focusable="true"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"        
        android:inputType="textVisiblePassword|textCapWords|textMultiLine"
        android:textIsSelectable="true"
        android:gravity="top|left"
        android:minLines="6"
        android:maxLines="10"
        android:minHeight="140dp"
        android:hint="@string/message">
      <requestFocus />
<EditText/>
like image 27
gunar Avatar answered Oct 16 '22 07:10

gunar