Can id resources refer to an element later in the file?
Here I have two fields, one for the username, and another for the password. I create a new ID resource (with the @+id/
syntax) for the password field, but the username field cannot find it in the android:nextFocusDown
field. I have omitted other fields from the layout xml, because they aren't relevant.
How would I need to declare the IDs in this case?
<EditText
android:id="@+id/login_username"
android:nextFocusDown="@id/login_password" />
<EditText
android:id="@+id/login_password"
android:nextFocusUp="@id/login_username"
android:nextFocusDown="@id/login_submit" />
Building with gradle, I'm getting an error that looks like this: Error:(41, 32) No resource found that matches the given name (at 'nextFocusDown' with value '@id/login_password').
I do not get an error for android:nextFocusUp="@id/login_username"
field, which leads me to believe you must declare the id before you use it.
I also get compile errors in my code, because no R.java
file is being generated, most likely because the resources it builds from aren't building either.
With all the fancy build tools in android, I'm surprised this is a problem. Is this a known problem or desired behavior?