Reputation: 1189
I am using ListViewAdapter for binding ListView on my home page, and a custom keyboard. But when I clicked on EditText, the default keyboard displays.
I tried to hide it by using the following code:
InputMethodManager mgr = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(diesel.getWindowToken(), 0);
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
But it didn't work.
How can I hide the default keyboard from ListViewAdapter?
Upvotes: 6
Views: 3586
Reputation: 3364
If you want to hide the keyboard on events like click of button, use this
public void onClick(View v)
{
InputMethodManager imm = (InputMethodManager) v.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
Upvotes: 5
Reputation: 1189
Finally i got it. i solved this problem. just added below line in ListViewAdapter.
(EditTextName).setInputType(0);
Now it will not open Default Keyboard on EditText Click or Touch.
Upvotes: 5
Reputation: 75646
Adapter is not the right place to do any UI related activities.
Upvotes: 4