I have the following inside a relative layout.
<TextEdit
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/buttonA"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/buttonA" />
<Button
android:id="@+id/buttonA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/message" >
</Button>
Eclipse gives me these errors at lines android:layout_alignBottom=”@id/buttonA” and android:layout_toLeftOf=”@id/buttonA” respectively:
error: Error: No resource found that matches the given name (at ‘layout_alignBottom’ with value ‘@id/buttonA’).
error: Error: No resource found that matches the given name (at ‘layout_toLeftOf’ with value ‘@id/buttonA’).
Replacing @id/buttonA with @+id/buttonA removes this eclipse error message. Is that the right thing to do? If so, why would that work instead? Doesn’t @+id create a new id? I don’t want a new id. I want to use the one referenced in the button object. What is the best way to deal with this?
Thanks guys. -Joe
Using
@+idis the right way to do it.@+idcreates a new id but only if one with that name doesn’t already exist.If you don’t want to do that, for this particular simple case it would suffice to move the
TextEditbelow theButton.