Reputation: 1730
In my application i have one edittext with one image for add the task into database.My problem is when i add the task in database after that the android soft keyboard visible instead of closing.I am using all those examples in stack overflow but not getting result please any one help me...
<EditText
android:id="@+id/edittextidAddTodayTask"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/edittextselector"
android:drawableRight="@drawable/addtask"
android:hint="AddTask"
android:singleLine="true"
/>
MyOnRightdrawable listener:
edittextAddTask.setOnTouchListener(new RightDrawableOnTouchListener(
edittextAddTask) {
@Override
boolean onDrawableTouch(MotionEvent event) {
//Add the task in db.
//I am using this code but not working for me
/*InputMethodManager mgr = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(edittextAddTask.getWindowToken(), 0);*/
}
My Screenshot for edittext:
Upvotes: 0
Views: 179
Reputation: 3195
try this
edtText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittextAddTask.getWindowToken(), 0);
}
});
Upvotes: 0