0

I am trying to add a spinner to my layout via Eclipse. I have added an item in the .xml, but the item is not displaying in the graphical layout. All I get are green arrows.

Here is what I'm seeing: Graphical Layout

Here is the .xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.gui_test.MainActivity$PlaceholderFragment" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:layout_centerHorizontal="true" >
    </ListView>

    <Button
        android:id="@+id/submitButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/listView1"
        android:layout_below="@+id/listView1"
        android:layout_marginTop="17dp"
        android:text="Submit" />

    <Button
        android:id="@+id/refreshButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/submitButton"
        android:layout_alignBottom="@+id/submitButton"
        android:layout_alignLeft="@+id/listView1"
        android:text="Refresh" />

    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/submitButton"
        android:layout_alignRight="@+id/refreshButton"
        android:layout_below="@+id/listView1"
        android:layout_marginRight="5dp" 
        android:layout_marginLeft="5dp"/>

</RelativeLayout>

I want the spinner to sit in between the "Refresh" and "Submit" buttons. How do I do this?

2
  • You have to show us the code to your RelativeLayout but as I can see from your code that the spinner is invisible because you are using alignRight and alignLeft wrong Commented Nov 12, 2014 at 22:59
  • Edited to add the full .xml layout. Commented Nov 12, 2014 at 23:06

1 Answer 1

1

Try removing alignLeft and alignRight and add android:layout_centerHorizontal="true" then you can also add android:layout_alignTop="@+id/refreshButton" to align the spinner with the buttons from the top

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.