Edittext without Focus by Activity

Asked

Viewed 459 times

1

Is there any command in the Activity that prevents a EditText to receive focus even with the user clicking? Or this can only be done by XML?

I have a repository that is connected to a database and I need that repository to be filled in before the user fills in the fields. So until the user Incronize for the first time, he will not be able to fill in the fields.

So I need a way to stop the EditText until such repository is completed.

  • Read-only mode maybe? Only then the field cannot be edited.

  • @diegofm .

2 answers

5


Hello, see if any of the methods below help you.

edittext.setFocusableInTouchMode(boolean)
edittext.setFocusable(boolean)

After you finish loading you enable again (you can use the setEnabled(boolean) also).

  • That’s what I was looking for

  • All right then, good jobs.

1

You can do this in the code itself by doing the following:

EditText edt = (EditText) findViewById(R.id.edt);
edt.setFocusable(false);
  • This will not only remove the focus, but will lock the component as well.

  • That’s it, I was wrong, you have to use the following: edt.setFocusable(false);

  • Edit the answer then, you still have the wrong method.

  • Thanks for reminding me! It’s already edited!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.