我在我的应用程序的自定义键盘。问题是如何当上点击edittext.I的使用setonfocuschangre监听器,现在看来custon keyboaed展架这款键盘时的EditText焦点changed.but我想说明这个键盘每当我在edittext..one信息,我忘了点击把这里的EditText是片段中。
I have a custom keyboard in my application. question is How to didplay this keyboard when click on the edittext.I an using setonfocuschangre listener ,now the custon keyboaed appears when the edittext focus is changed.but i want to show this keyboard whenever i click on the edittext..one info I forget to put here the edittext is within the fragment.
您可以尝试这样的事情
edittext.setOnClickListener(new OnClickListener() {
// NOTE By setting the on click listener, we can show the custom keyboard again,
// by tapping on an edit box that already had focus (but that had the keyboard hidden).
@Override public void onClick(View v) {
showCustomKeyboard(v);
}
});
// Disable standard keyboard hard way
// NOTE There is also an easy way: 'edittext.setInputType(InputType.TYPE_NULL)'
// (but you will not have a cursor, and no 'edittext.setCursorVisible(true)' doesn't work )
edittext.setOnTouchListener(new OnTouchListener() {
@Override public boolean onTouch(View v, MotionEvent event) {
EditText edittext = (EditText) v;
int inType = edittext.getInputType(); // Backup the input type
edittext.setInputType(InputType.TYPE_NULL); // Disable standard keyboard
edittext.onTouchEvent(event); // Call native handler
edittext.setInputType(inType); // Restore input type
return true; // Consume touch event
}
});
// Disable spell check (hex strings look like words to Android)
edittext.setInputType(edittext.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
有关详细信息查询这里