Multiple EditText fields per row


Last Updated:

  1. Alex A

    Alex A New Member This Topic's Starter

    Joined:
    Jul 26, 2009
    Messages:
    1
    Likes Received:
    0
    Hi all,

    I started Android development this morning, and that's pretty much what I was doing all day :)
    It's very exciting and Eclipse plug in is so easy to use!!! Here's a little problem that I ran into with XML.

    Trying to put 4 EditText fields in one row of a TableLayout as
    follows:

    Code (Text):
    1. <TableLayout
    2.         android:layout_height="fill_parent"
    3.         android:layout_width="fill_parent"
    4.         android:id="@+id/MainText>
    5.  
    6. <TableRow
    7.         android:id="@+id/Row1"
    8.         android:layout_width="wrap_content"
    9.         android:layout_height="wrap_content">
    10.  
    11.     <TextView
    12.         android:id="@+id/label1"
    13.         android:layout_width="wrap_content"
    14.         android:layout_height="wrap_content"
    15.         android:text="@string/first"/>
    16. </TableRow>
    17.  
    18. <TableRow
    19.         android:id="@+id/Row2"
    20.         android:layout_width="wrap_content"
    21.         android:layout_height="wrap_content">
    22.  
    23.     <EditText
    24.         android:id="@+id/inputField1"
    25.         android:layout_column="0"
    26.         android:layout_width="30dip"
    27.         android:layout_height="wrap_content"
    28.         android:padding="3dip"/>
    29.  
    30.     <EditText
    31.         android:id="@+id/inputField2"
    32.         android:layout_column="1"
    33.         android:layout_width="30dip"
    34.         android:layout_height="wrap_content"
    35.         android:padding="3dip"/>
    36.  
    37.     <EditText
    38.         android:id="@+id/inputField3"
    39.         android:layout_column="2"
    40.         android:layout_width="30dip"
    41.         android:layout_height="wrap_content"
    42.         android:padding="3dip"/>
    43.  
    44.     <EditText
    45.         android:id="@+id/inputField4"
    46.         android:layout_column="3"
    47.         android:layout_width="30dip"
    48.         android:layout_height="wrap_content"
    49.         android:padding="3dip"/>
    50. </TableRow>
    51.  
    52. </TableLayout>
    But what this results in is just one EditText field (the first one) taking up the whole second row. What I need is all 4 entry fields in one row.
    What is the problem here?
    Any help is appreciated.

    Alex
     

    Advertisement
  2. KlaymenDK

    KlaymenDK Well-Known Member

    Joined:
    May 29, 2009
    Messages:
    1,217
    Likes Received:
    130
    I haven't used tables very much; I prefer to use LinearLayout -- if you nest horizontals inside a vertical, you'll get almost the same effect.

    I did spot this in TableLayout, however, indicating your TableRow's need a little reviewing:
    This brief example mentions sizing in table cells; you seem to be on the right track there.

    Hope this helps.
     

Share This Page

Loading...