Skip to content

Commit

Permalink
fix(android): drop-down picker to never accept keyboard input
Browse files Browse the repository at this point in the history
  • Loading branch information
jquick-axway authored and ewanharris committed Jan 13, 2022
1 parent 23986a3 commit 2dad43e
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.text.Editable;
import android.text.InputType;
import android.text.method.BaseKeyListener;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
Expand Down Expand Up @@ -182,7 +187,24 @@ public TextInputLayout createTextInputLayout()
editText.setSingleLine();
editText.setMaxLines(1);
editText.setGravity(Gravity.CENTER_VERTICAL | Gravity.START);
editText.setInputType(0);
editText.setKeyListener(new BaseKeyListener() {
@Override
public int getInputType()
{
return InputType.TYPE_NULL;
}
@Override
public boolean backspace(View view, Editable content, int keyCode, KeyEvent event)
{
return false;
}
@Override
public boolean forwardDelete(View view, Editable content, int keyCode, KeyEvent event)
{
return false;
}
});
editText.setRawInputType(InputType.TYPE_NULL);
if (textInputLayout.isHintEnabled() == false) {
// Remove extra padding from top since hint text is disabled.
editText.setPadding(
Expand Down

0 comments on commit 2dad43e

Please sign in to comment.