Pregunta

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
  <ListView
      android:layout_above="@id/btn_4"    <-- this line error: No resource found
      android:layout_width="match_parent"
      android:layout_height="200dp" />
  <Button android:id="@+id/btn_4"         <-- I declare the id here
      android:layout_alignParentBottom="true"
      android:layout_height="wrap_content"
      android:layout_width="match_parent" />
</RelativeLayout>

Any suggestions?

¿Fue útil?

Solución

As I understand it, the first time an id is used in a layout xml, it needs to have a + sign in front of it.

From the Declaring Layout docs:

The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in the R.java file).

So, add a '+' to the first btn_4 reference in the ListView layout and you can remove the unnecessary '+' from the android:id attribute in the Button layout.

Otros consejos

When you declare relative layouts, you have to use android:layout_above="@+id/layoutToBeAbove"

Otherwise, the system does not know what you're pointing at.

This declaration will point at the same resource.

Hope this helped!

Declare the ListView list_1 after declaring the Button btn_4 as it tries to reference it in android:layout_above="@id/btn_4".

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top