I want to override the back button when the soft keyboard is displayed. Basically, when the back button is pressed, I want the keyboard to decline, and I want to add some text to what the user typed in this edit text box. So basically I need to know when the keyboard deviates. After searching, I realized that there is no API for this, and your EditText class will be the only real way to do this.
So, I created my own EditText class and an extended EditText like this
public class CustomEditText extends EditText
{
public CustomEditText(Context context)
{
super(context);
init();
}
public CustomEditText(Context context, AttributeSet attrs)
{
super(context, attrs);
init();
}
public CustomEditText(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
init();
}
private void init()
{
}
}
I also added this method
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event)
{
if (KeyEvent.KEYCODE_BACK == event.getKeyCode())
{
Log.v("", "Back Pressed");
}
return super.dispatchKeyEventPreIme(event);
}
Now this method overrides the "Back" button, it closes the keyboard, but I do not know how to transfer text to the EditText field. Does anyone know how I will do this?
: - , ? , , , , "", , - , ?
!