EditText without Focus by Activity

1

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

I have a repository that is connected to a database and I need this repository to be populated before the user populates the fields. Therefore, until the user synchronizes for the first time, he can not fill in the fields.

So I need a way to lock EditText until this repository is populated.

    
asked by anonymous 03.08.2016 / 13:48

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 it again (you can use setEnabled(boolean) too).

    
03.08.2016 / 13:59
1

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

EditText edt = (EditText) findViewById(R.id.edt);
edt.setFocusable(false);
    
03.08.2016 / 15:01