N
N
neuralnetwork20202021-08-11 20:29:15
Kotlin
neuralnetwork2020, 2021-08-11 20:29:15

Android studio throws an error android resource linking failed? when trying to create a list.

I'm trying to create a list in my android app, added spinner widget in xml file

normal/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:ignore="MissingConstraints">

    <ImageButton
        android:id="@+id/black"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="67dp"
        android:src="@drawable/black"
        />

    <ImageButton
        android:id="@+id/blue"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/blue"
        />

    <ImageButton
        android:id="@+id/brown"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/brown"
        />

    <ImageButton
        android:id="@+id/gray"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/gray"
        />

    <ImageButton
        android:id="@+id/green"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/green"
        />

    <ImageView
        android:id="@+id/open"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_marginLeft="315dp"
        android:layout_marginTop="-80dp"
        android:src="@drawable/open" />

    <ImageView
        android:id="@+id/save"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_marginLeft="315dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/save" />

    <ImageButton
        android:id="@+id/purple"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="-10dp"
        android:src="@drawable/purple"
        />

    <ImageButton
        android:id="@+id/red"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/red"
        />

    <ImageButton
        android:id="@+id/yellow"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/yellow"
        />

    <EditText
        android:id="@+id/text"
        android:layout_width="240dp"
        android:layout_height="430dp"
        android:layout_marginLeft="60dp"
        android:layout_marginTop="-425dp"
        android:gravity="top"
        android:inputType="textMultiLine"
        android:scrollHorizontally="false"
        android:scrollbars="vertical"
        />

    <ImageView
        android:id="@+id/justify"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="75dp"
        android:layout_marginTop="0dp"
        android:onClick="TextJustify"
        android:src="@drawable/justify"
        />

    <ImageView
        android:id="@+id/center"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="-40dp"
        android:onClick="TextCenter"
        android:src="@drawable/center"
        />

    <ImageView
        android:id="@+id/left"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="180dp"
        android:layout_marginTop="-42dp"
        android:onClick="TextLeft"
        android:src="@drawable/left"
        />

    <ImageView
        android:id="@+id/right"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="235dp"
        android:layout_marginTop="-35dp"
        android:onClick="TextRight"
        android:src="@drawable/right"
        />

    <ImageView
        android:id="@+id/exist"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginLeft="315dp"
        android:layout_marginTop="-480dp"
        android:onClick="Close"
        android:src="@drawable/exist"
        />

        <Spinner
            android:id="@+id/size"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_marginLeft="80dp"
            android:layout_marginTop="-40dp"
            android:entries="@array/sizes"
            />


    </LinearLayout>

</android.support.constraint.ConstraintLayout>


But when I try to populate the Spinner list by changing the contents of the strings.xml file, I get the error "android resource linking failed"

strings.xml
<resources>
    <string-array name="sizes">
        <item>5</item>
        <item>10</item>
        <item>15</item>
    </string-array>
</resources>


And it throws me into the AndroidManifest.xml file

AndroidManifest.xml
611406d16b52b327590831.png


Build
611406df884b1415995272.png


When I try to create a list, through the "ListView" widget, it throws the same error. How to fix this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MinTnt, 2021-08-11
@neuralnetwork2020

In strings.xml, there must also be all those parameters that are accessed by the resource in other xml files of the interface. In this case AndroidManifest.xml

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question