Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent keypad from hiding like whatsapp while click on send button and make continuous focus on edit text in android

I want to prevent soft keypad from hiding from edittext while click on send button in my messaging app like in whatsapp while we click on send button but softkeypad does not disappear I have tried to requestfocus on edit text and showing keypad but it shakes keypad like it goes down and then come up. Please can any one help me regarding this issue.

like image 604
user3269550 Avatar asked Oct 29 '22 12:10

user3269550


2 Answers

Try this in onCreate, it will forcely open softkeyboard-

 ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

To hide it, use below code-

((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(_pay_box_helper.getWindowToken(), 0)

In your manifest-

<activity android:windowSoftInputMode="stateAlwaysVisible" ... />
like image 110
karanatwal.github.io Avatar answered Nov 15 '22 05:11

karanatwal.github.io


Give android:nextFocusDown to same EditText id.

<EditText
                android:id="@+id/loginPassword"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:hint="@string/password"
                android:imeOptions="actionSend"
                android:nextFocusDown="@id/loginPassword"
                android:inputType="textPassword" />
like image 22
Pratik Popat Avatar answered Nov 15 '22 06:11

Pratik Popat