Xml question


#1

in my activity_quiz.xml document I need to add: “android:id=”@+id/false_button"" to get an ID for the button in the R.java file.
whereas in strings.xml I only typed in “Constantinople is the largest city in Turkey.” and then question_text ID appeared in R.java.

So in the second case I didnt have to type +id anywhere in order for the ID to appear in R.java, why is that? Does it have to do with the root in strings.xml? The root in strings.xml is . So maybe all the text inside that root goes directly to R.java.

Another very importat thing is that I think we should have one thread where people can ask these more general programming questions. So one doesnt have to start a new thread each time a question appears.

Swedish regards
//knixer


#2

I’m new to Android as well, so this is just speculation on my part, but I think it’s because Android generates resource ID’s for strings and the top level layout automatically, but it doesn’t do it for the child resources within the layout, since you won’t always need to reference them.

On page 17 of the book it says “Android generated a resource ID for the entire layout and for each string, but it did not generate IDs for the individual widgets in activity_quiz.xml. Not every widget needs a resource ID.”

I agree about a general programming questions thread, btw.