I have a edittext which needs to function like the textfield in iOS. When I click on it, should become editable else it should be disabled. Let's say the user wants to edit a certain value and when he presses the back button, along with the keyboard dismiss I want the edittext to become disabled to edit.
All I am using is the setCursorVisible(true) and setCursorVisible(false) method. I did try using keyCode events but they aren't helping. This is what I have tried up until now:
@Override
public void onBackPressed() {
// Had the InputMethodManager service here..
if(imm.isAcceptingText())
{
Toast.makeText(ProfileActivity.this,"working",Toast.LENGTH_SHORT).show();
}
else {
super.onBackPressed();
Toast.makeText(ProfileActivity.this,"back pressed called",Toast.LENGTH_SHORT).show();
}
}
Also tried overriding keyDown event.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//replaces the default 'Back' button action
if(keyCode==KeyEvent.KEYCODE_BACK)
{
Log.d("123","called,called");
return true;
}
return super.onKeyDown(keyCode, event);
}