I am trying to capture when an edittext field which is disabled gets pressed. (I only want to change it, I dont want text inserted into it). I assigned an onClickListener to it but it is not called.. Any suggestions ? Is there any other event I can listen to ?
final EditText field = column.get(i);
field.setEnabled(false);
field.setClickable(true);
field.setFocusable(false);
field.setFocusableInTouchMode(false);
field.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((EditText)v).setText("a");
}
});
Thanks !
You cant pass a click-event when a View
is disabled.
Therefore, try changing:
field.setEnabled(false);
To:
field.setEnabled(true);
final EditText field = column.get(i);
field.setCursorVisible(false);
field.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
field.setText("something");
field.clearFocus();
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With