========================================================== =============================== Original blog, reprinted please declare the source of Electronic coffee (original id blue rock) ========================================================== ================================
Android relativelayout Error
Error: no resource found that matches the given name (at 'yout _ toleftof 'with value' @ ID/
Main_auto_checkbox ').
Later I found out that I referenced the ID of B in A, but the ID of B is declared later, and the compiler is executed in sequence (in my opinion), so I cannot find it, when I put the statement of B in front of a, it's okay,
<Relativelayout Android: Orientation = "horizontal" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: gravity = "center"> <textview Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: gravity = "center" Android: layout_toleftof = "@ ID/main_auto_checkbox" -- the error is returned, android: text = "auto-fix" Android: layout_centervertical = "true"/> <checkbox Android: id = "@ + ID/main_auto_checkbox" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignparentright = "true" Android: layout_marginright = "3dip"/> </relativelayout>
, Change the Declaration Order of the checkbox and textview. This is correct.
<Relativelayout Android: Orientation = "horizontal" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: gravity = "center"> <checkbox Android: id = "@ + ID/main_auto_checkbox" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignparentright = "true" Android: layout_marginright = "3dip"/> <textview Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: gravity = "center" Android: layout_toleftof = "@ ID/main_auto_checkbox" Android: text = "auto fix" Android: layout_centervertical = "true"/> </relativelayout>