onClick on edittext that can not be editable

1

How to make an event click on an edittext, enabled="false"? (I could not do without focus being in edittext, enabled="true")

Or, an event clicks on an edittext that can not be edited.

Code below:

....

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:maxLength="20"
            android:textColorHint="#FFF8E1"
            android:theme="@style/StyledTilEditText"
            android:clickable="true"
            android:id="@+id/pass_conta">

            <EditText
                android:id="@+id/edt_Password_conta"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:fontFamily="sans-serif-condensed"
                android:hint="@string/senha_hint_string"
                android:inputType="textPassword"
                android:maxLength="20"
                android:maxLines="1"
                android:text="123456"
                android:singleLine="true"
                android:textColor="#D3D3D3"
                android:textSize="15dp"
                android:clickable="true"
                android:enabled="false"/>

        </android.support.design.widget.TextInputLayout>
....

Code in activity:

.....
        mSenha.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext());
                dialogBuilder.setTitle("Deseja alterar a senha?")
                        .setMessage("Para alterar a senha é necessário fazer logoff e entrar em \"\"Esqueci a Senha\"\"")
                        .setCancelable(true)
                        .setPositiveButton("Sim", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                SaveSharedPreferences.clearLoginPreferences(getContext());
                                intent = new Intent(AlterarContaActivity.this,NewLoginActivity.class);
                                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                                startActivity(intent);
                                Toast("Digite o email e vá em esqueci a senha");
                            }
                        }).setNegativeButton("Não", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                }).show();
            }
        });

......
    
asked by anonymous 09.11.2016 / 15:11

2 answers

1

Try:

android:focusable="false"
android:enabled="true"
    
09.11.2016 / 15:40
1

Do you want EditText to receive focus without being editable? If so, just call

editText.setKeyListener(null);

If you want it to be editable again, before you set the listener to null, obtain and store the original listener with

editText.getKeyListener();
    
09.11.2016 / 16:28