Change ListView layout background color depend on special condition
<p>I create a <code>ListView</code> in a <code>Fragment</code> and use a <code>SimpleAdapter</code> to set layout and values.  </p>

<p>Now I want to change background of a <code>LinearLayout</code> in layout that I use in <code>ListView</code> depend on the text that sets for <code>ListView</code>.<br>
Something like this:</p>

<p><a href="https://i.stack.imgur.com/SFOOU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SFOOU.png" alt="Something Like This"></a></p>

<p>This is my layout XML.<br>
I want change color of LinearLayout with <code>list</code> id.</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:background="@drawable/layout_shadow"
    android:layout_height="207dp"&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:background="@color/colorPrimary"
        android:layout_height="193dp"
        android:layout_marginLeft="6dp"
        android:layout_marginRight="6dp"
        android:id="@+id/list"&gt;

        &lt;LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"&gt;

            &lt;TextView
                android:text="magnitude"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/fValue"
                android:textStyle="bold"
                android:textColor="@android:color/white"
                android:textSize="20sp"
                android:layout_margin="5dp" /&gt;
        &lt;/LinearLayout&gt;

        &lt;LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"&gt;

            &lt;TextView
                android:text="region"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/sValue"
                android:textColor="@android:color/white" /&gt;
        &lt;/LinearLayout&gt;

        &lt;ImageView
            android:layout_width="match_parent"
            app:srcCompat="@drawable/no_image"
            android:id="@+id/mImage"
            android:layout_height="143dp" /&gt;
    &lt;/LinearLayout&gt;
&lt;/RelativeLayout&gt;
</code></pre>