简体   繁体   中英

Click anywhere in EditText to show keyboard

I am trying to make Hello World notepad app, and currently I have to click right on the cursor in my EditText to bring up the soft keyboard. I would like to be able to click anywhere in the EditText to show the keyboard.

Here is my EditText declaration in my layout:

<EditText
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="text"  >
</EditText>

EDIT:

I am using the Galaxy Nexus emulator, and here is what I get:

屏幕

I have to click in the area above the blue marker to get the keyboard.

Try this :

<EditText
    android:id="@+id/text"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:inputType="text"  >
</EditText>

Use below code for showing softkeyboard when your edittext get focus for example

youredittext.setOnFocusChangeListener(new OnFocusChangeListener() 
{

@Override
public void onFocusChange(View v, boolean hasFocus) {

if(hasFocus)                                
{

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInputFromInputMethod(youeedittext.getWindowToken(), 0);

}   



}



});

This will show Soft keyboard each time your edittext gewt focus ...if not work use same code in OnClick event for your edittext...

or

Check this in AVD Manager 在此处输入图片说明

Hope it helps..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM