I have created customview. Whenever user double taps on the view it should display the keyboard and user can draw new Text.
Holder is a customview which extends view. But it's showing the keyboard. How to get the text?
public Holder(Context context, AttributeSet attrs) {
super(context, attrs);
Log.e(TAG,"EXE");
imm = (InputMethodManager)
context. getSystemService(Context.INPUT_METHOD_SERVICE);
public boolean onDoubleTap(MotionEvent e) {
View view = Holder.this.getRootView();
imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
// imm.showSoftInput(Holder.this, InputMethodManager.SHOW_FORCED); not working
Try to create edittext dynamically and send the value to view.Here is my code.its best alternative ..
public class CustomEditText extends EditText {
private KeyImeChange keyImeChangeListener;
public CustomEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public CustomEditText(Context context) {
super(context);
}
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setKeyImeChangeListener(KeyImeChange listener){
keyImeChangeListener = listener;
}
public interface KeyImeChange {
public void onKeyIme(int keyCode, KeyEvent event);
}
@Override
public boolean onKeyPreIme (int keyCode, KeyEvent event){
if(keyImeChangeListener != null){
keyImeChangeListener.onKeyIme(keyCode, event);
}
return false;
}
}
MainActivity.editText2.setKeyImeChangeListener(new CustomEditText.KeyImeChange() {
@Override
public void onKeyIme(int keyCode, KeyEvent event) {
//Update view on keyboard close
invalidate();
}
});