Hey..
i designed a simple linear layout for some inputs using the visual
editor of eclipse. The api version of my app is 2.0

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TableLayout android:layout_width="fill_parent" android:id="@+id/
parties" android:layout_height="wrap_content">
        <TableRow android:layout_weight="1" android:id="@+id/party1"
android:layout_width="wrap_content" android:layout_height="0dp">
            <AutoCompleteTextView android:text=""
android:layout_height="wrap_content" android:id="@+id/party1_name"
android:layout_width="0dp" android:completionHintView="@array/
parteien" android:layout_weight="1"  android:singleLine="true">
                <requestFocus></requestFocus>
            </AutoCompleteTextView>
            <EditText android:id="@+id/party1_votes"
android:layout_height="wrap_content" android:inputType="number"
android:layout_weight="1" android:layout_width="0dp"
android:singleLine="true"></EditText>
        </TableRow>
    </TableLayout>
</LinearLayout>

Now i want to add more rows the table if the user wants more input
fields:

onCreate already sets:
TableLayout parties = (TableLayout) findViewById(R.id.parties);

and i wrote a function:
        // first we need a new row
        TableRow newRow = new TableRow(this);
        newRow.setLayoutParams(new TableLayout.LayoutParams(
                        LayoutParams.WRAP_CONTENT,
                        LayoutParams.WRAP_CONTENT
        ));
        newRow.setWeightSum(2f);

        // then we add a new AutoCompleteTextView
        AutoCompleteTextView newParty = new AutoCompleteTextView(this);

        newParty.setLines(1);

        // and an EditText
        EditText newPartyVotes = new EditText(this);

        newPartyVotes.setLines(1);

        // add both to the row
        newRow.addView(newParty);
        newRow.addView(newPartyVotes);


        // and the row to the table
        parties.addView(newRow, new TableLayout.LayoutParams(
                        LayoutParams.FILL_PARENT,
                        LayoutParams.WRAP_CONTENT
        ));

I now have two problems::
1. The input field are small.
Question: How can i set the layout weight so that the input fields
fill the table like the first ones? Or which function do i have to
call so that the width are calculated correctly.
2. If i add more fields than the display can show, they are not
scrollable. Additionally the first input fields are  first shown only
half and with the next row they disappear.
Question: How do i prevent this and make the fields scrollable? Or is
it just a display bug of the emulator? i have no android handy.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to