Setting text of a selected item on a spinner
<p>So I'm trying to show on a text view a selected item in a spinner,but I don't know why,it doesn't show the selected item on the spinner, it shows like an empty spinner and I would really appreciate if you can help me.
ps: All the items,in the spinners are String.</p>

<p>Java code:</p>

<pre><code>   setContentView(R.layout.activity_verpedido);

    RelativeLayout verpedido = (RelativeLayout) findViewById(R.id.verpedido);

    View sanduche = getLayoutInflater().inflate(R.layout.activity_aprisasanduche, null);

    verpedido.addView(sanduche);

    String item1, item2;
    int price;
    TextView tvItem1, tvItem2, tvItem3, tvItem4;
    Spinner Sping1, Sping2, Sping3, Sping4;
    String Ssanduche1, Ssanduche2, Ssanduche3, Ssanduche4;

    Sping1 = (Spinner)findViewById(R.id.Sing1);
    Sping2 = (Spinner)findViewById(R.id.Sing2);
    Sping3 = (Spinner)findViewById(R.id.Sing3);
    Sping4 = (Spinner)findViewById(R.id.Sing4);

    tvItem1 = (TextView)findViewById(R.id.vering1);
    tvItem2 = (TextView)findViewById(R.id.vering2);
    tvItem3 = (TextView)findViewById(R.id.vering3);
    tvItem4 = (TextView)findViewById(R.id.vering4);

    Ssanduche1 = (String) Sping1.getSelectedItem();
    Ssanduche2 = (String) Sping2.getSelectedItem();
    Ssanduche3 = (String) Sping3.getSelectedItem();
    Ssanduche4 = (String) Sping4.getSelectedItem();

    tvItem1.setText(Ssanduche1);
    tvItem2.setText(Ssanduche2);
    tvItem3.setText(Ssanduche3);
    tvItem4.setText(Ssanduche4);
</code></pre>

<p>.xml principal </p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/verpedido"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.unlunch.unlunch.VerPedido"
    android:background="#CC2124"
    &gt;
    &lt;TextView
        android:id="@+id/ting1"
        android:text="@string/Str_ing1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:layout_marginLeft="10dp"
        android:textColor="#FFF1FE"
        android:textColorHint= "#7A02CC"
        android:textSize="17dp"
        android:textStyle="italic"
        /&gt;

    &lt;TextView
        android:id="@+id/vering1"
        android:text=" "
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ting1"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="false"
        android:textColor="#FFF1FE"
        android:textColorHint= "#7A02CC"
        android:textSize="17dp"
        android:textStyle="italic"
        /&gt;

    &lt;TextView
        android:id="@+id/ting2"
        android:text="@string/Str_ing2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="10dp"
        android:textColor="#FFF1FE"
        android:textSize="17dp"
        android:textStyle="italic"
        android:layout_below="@+id/vering1"
        /&gt;

    &lt;TextView
        android:id="@+id/vering2"
        android:text=" "
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ting2"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="false"
        android:textColor="#FFF1FE"
        android:textColorHint= "#7A02CC"
        android:textSize="17dp"
        android:textStyle="italic"
        /&gt;

    &lt;TextView
        android:id="@+id/ting3"
        android:text="@string/Str_ing3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/vering2"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="false"
        android:textColor="#FFF1FE"
        android:textSize="17dp"
        android:textStyle="italic"
        /&gt;

    &lt;TextView
        android:id="@+id/vering3"
        android:text=" "
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ting3"
        android:layout_marginTop="50dp"
        android:layout_marginLeft="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="false"
        android:textColor="#FFF1FE"
        android:textColorHint= "#7A02CC"
        android:textSize="17dp"
        android:textStyle="italic"
        /&gt;

    &lt;TextView
        android:id="@+id/ting4"
        android:text="@string/Str_ing4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/vering3"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="false"
        android:textColor="#FFF1FE"
        android:textSize="17dp"
        android:textStyle="italic"
        /&gt;

    &lt;TextView
        android:id="@+id/vering4"
        android:text=" "
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/ting4"
        android:layout_marginTop="50dp"
        android:layout_marginLeft="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="false"
        android:textColor="#FFF1FE"
        android:textColorHint= "#7A02CC"
        android:textSize="17dp"
        android:textStyle="italic"
        /&gt;

&lt;/RelativeLayout&gt;</code></pre>
</div>
</div>
</p>

<p>.xml secondary </p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/sanduche"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.unlunch.unlunch.AprisaSanduche"
    android:background="#CC2124"
    &gt;
    &lt;TextView
        android:id="@+id/ting1"
        android:text="@string/Str_ing1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:layout_marginLeft="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="false"
        android:textColor="#FFF1FE"
        android:textColorHint= "#7A02CC"
        android:textSize="17dp"
        android:textStyle="italic"
        /&gt;
    &lt;Spinner
        android:id="@+id/Sing1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_alignLeft="@+id/ting1"
        android:layout_alignStart="@+id/ting1"
        android:popupBackground="#CC413D"
        android:layout_below="@+id/ting1"
        /&gt;

    &lt;TextView
        android:id="@+id/ting2"
        android:text="@string/Str_ing2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="10dp"
        android:textColor="#FFF1FE"
        android:textSize="17dp"
        android:textStyle="italic"
        android:layout_below="@+id/Sing1"
        /&gt;
    &lt;Spinner
        android:id="@+id/Sing2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_below="@+id/ting2"
        android:layout_alignLeft="@+id/ting2"
        android:layout_alignStart="@+id/ting2"
        android:popupBackground="#CC413D"
        /&gt;

    &lt;TextView
        android:id="@+id/ting3"
        android:text="@string/Str_ing3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Sing2"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="false"
        android:textColor="#FFF1FE"
        android:textSize="17dp"
        android:textStyle="italic"
        /&gt;
    &lt;Spinner
        android:id="@+id/Sing3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_below="@+id/ting3"
        android:layout_alignLeft="@+id/ting3"
        android:layout_alignStart="@+id/ting3"
        android:popupBackground="#CC413D"
        /&gt;

    &lt;TextView
        android:id="@+id/ting4"
        android:text="@string/Str_ing4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Sing3"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="false"
        android:textColor="#FFF1FE"
        android:textSize="17dp"
        android:textStyle="italic"
        /&gt;
    &lt;Spinner
        android:id="@+id/Sing4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_below="@+id/ting4"
        android:layout_alignLeft="@+id/ting4"
        android:layout_alignStart="@+id/ting4"
        android:popupBackground="#CC413D"
        /&gt;

    &lt;Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Str_ver"
        android:id="@+id/verBt"
        android:layout_marginTop="50dp"
        android:layout_marginLeft="10dp"
        android:layout_below="@+id/Sing4"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        /&gt;

    &lt;Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Str_back"
        android:id="@+id/backBt"
        android:layout_marginTop="0dp"
        android:layout_marginLeft="10dp"
        android:layout_below="@+id/verBt"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        /&gt;
&lt;/RelativeLayout&gt;</code></pre>
</div>
</div>
</p>