Hi,

Below is some test code that tries to create a TableRow dynamically.
One of the columns contains an EditText the other a single button.
Initially the TableLayout contains a single row from the main.xml
layout.  There is a button on the screen (plus icon) adds a new row.
The problem is that if the user launches the app, clicks on the plus
icon to create a new row and then touches the new row's EditText the
soft keyboard won't launch.  If the user creates the new row, touches
the EditText of the row that is created by main.xml, the keyboard
launches and further touches to the previously created row (row 1)
start working.  This continues where if the user creates a new row,
that new row's EditText won't launch the soft keyboard until one of
the previous working rows launch the keyboard.

Clear as mud ;-)?  The code is below.  Any help would be appreciated!
-justin

------------main.xml-----------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01" xmlns:android="http://
schemas.android.com/apk/res/android" android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content">

<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/
RelativeLayout02">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/headerTextView_"
android:text="Header1" android:layout_gravity="center_vertical"
android:paddingLeft="10px" android:layout_centerVertical="false"
android:paddingTop="12px"></TextView>
<ImageButton android:id="@+id/textExRuleAddBtn_"
android:layout_height="wrap_content" android:src="@android:drawable/
ic_input_add"  android:focusable="false" android:paddingBottom="3px"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="false"></ImageButton>
</RelativeLayout>

<ScrollView android:id="@+id/ScrollView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:scrollbarSize="5px">
<TableLayout
  xmlns:android="http://schemas.android.com/apk/res/android";
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:stretchColumns="1" android:id="@+id/textExTable_">

        <TableRow>
                <Button android:id="@+id/textExRuleBtn_"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Button"></Button>
                <EditText android:id="@+id/textExRuleTxt_"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></EditText>
        </TableRow>

</TableLayout>
</ScrollView>
</LinearLayout>

-----------end main.xml-----------

---------mainactivity.java------------

package local.sandbox.dynamictable;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class MainActivity extends Activity implements OnClickListener
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ImageButton addBtn = (ImageButton)findViewById
(R.id.textExRuleAddBtn_);
                addBtn.setOnClickListener(this);
    }

        void addRow(String ruleType, String ruleText)
        {
                TableRow row = new TableRow(this);
                Button btn = new Button(this);

                EditText txt = new EditText(this);
                txt.requestFocus();

                TableLayout table_ = (TableLayout)this.findViewById
(R.id.textExTable_);
                table_.addView(row);
                row.addView(btn);
                row.addView(txt);
        }

        @Override
        public void onClick(View v) {
                addRow("hello","world");
        }
}

--------end mainactivity.java

-- 
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