Row cannot add dynamically using code to Table Layout in Android

Nisfan

I just want to add new rows at run time, and I tried using following codes..

java file ::>

TableLayout caseTable = (TableLayout) findViewById(R.id.caseTable);
TableRow caseRow = new TableRow(this);
caseRow.setOrientation(TableRow.VERTICAL);
EditText name = new EditText(this);
name.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));
name.setText("Name __");
caseRow.addView(name);
caseTable.addView(caseRow,new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));

xml file ::>

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:id="@+id/caseTable"
    android:stretchColumns="0,1,2,3">
    <TableRow>
        <TextView android:text="Case" />
        <TextView android:text="Details" />
    </TableRow>
</TableLayout>

I want to add new rows below the existing one. I get the code from here at stackOverFlow. But it didn't work. Thank you.

Prashant Bhoir

Just Simply Use The below code to add TableRow Programatically, perviously it is not working because you are trying to add TableLayout parameter to your EditText.

        TableLayout caseTable = (TableLayout) findViewById(R.id.caseTable);
        TableRow caseRow = new TableRow(this);
        caseRow.setOrientation(TableRow.VERTICAL);
        EditText name = new EditText(this);
        //name.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));
        name.setText("Name __");
        caseRow.addView(name);
        caseTable.addView(caseRow,new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Unable to get row id of dynamically added rows in table layout of android

From Dev

Cannot add table row using javascript

From Dev

How to add row dynamically in table layout or How to show full db Records in single table Layout

From Dev

Cannot Add Row to HTML Table in jsfiddle using add row button

From Dev

Cannot Add Row to HTML Table in jsfiddle using add row button

From Dev

Add a TextView dynamically in a layout ANDROID

From Dev

How to add dynamically a row to a table in the ejs using jquery?

From Dev

How to add dynamically a row to a table in the ejs using jquery?

From Dev

Add id to dynamically created row using bootstrap table in jquery

From Dev

How to add this type of layout dynamically (android)

From Dev

Dynamically Populate Data for Android Table Layout

From Dev

How to dynamically add ImageView to layout using Adapter

From Dev

AngularJS - add all values in table row dynamically

From Dev

dynamically add a table row with an onclick function

From Dev

add a row to a specific table created dynamically by user

From Dev

Add new table row to jQuery dynamically

From Dev

AngularJS - add all values in table row dynamically

From Dev

Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

From Dev

Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

From Dev

How do I dynamically add buttons using Java in a given XML layout file in android studio?

From Dev

GridView using Table Layout Android

From Dev

How can I dynamically add an HTML overlay to a table row using jQuery?

From Dev

Add/Delete row dynamically to/from jquery table using angularjs not working properly

From Dev

How to add a row dynamically in a tableLayout in Android

From Dev

How to add a row dynamically in a tableLayout in Android

From Dev

Unable to add dynamically row in TableLayout Android

From Dev

Changing layout in table row using CSS only

From Dev

Vuejs Add Table Row Dynamically - Save Row Problem

From Dev

Dynamically adding a row to a table using UJS

Related Related

  1. 1

    Unable to get row id of dynamically added rows in table layout of android

  2. 2

    Cannot add table row using javascript

  3. 3

    How to add row dynamically in table layout or How to show full db Records in single table Layout

  4. 4

    Cannot Add Row to HTML Table in jsfiddle using add row button

  5. 5

    Cannot Add Row to HTML Table in jsfiddle using add row button

  6. 6

    Add a TextView dynamically in a layout ANDROID

  7. 7

    How to add dynamically a row to a table in the ejs using jquery?

  8. 8

    How to add dynamically a row to a table in the ejs using jquery?

  9. 9

    Add id to dynamically created row using bootstrap table in jquery

  10. 10

    How to add this type of layout dynamically (android)

  11. 11

    Dynamically Populate Data for Android Table Layout

  12. 12

    How to dynamically add ImageView to layout using Adapter

  13. 13

    AngularJS - add all values in table row dynamically

  14. 14

    dynamically add a table row with an onclick function

  15. 15

    add a row to a specific table created dynamically by user

  16. 16

    Add new table row to jQuery dynamically

  17. 17

    AngularJS - add all values in table row dynamically

  18. 18

    Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

  19. 19

    Add Buttons to Relative Layout Dynamically or Extended Linear Layout android

  20. 20

    How do I dynamically add buttons using Java in a given XML layout file in android studio?

  21. 21

    GridView using Table Layout Android

  22. 22

    How can I dynamically add an HTML overlay to a table row using jQuery?

  23. 23

    Add/Delete row dynamically to/from jquery table using angularjs not working properly

  24. 24

    How to add a row dynamically in a tableLayout in Android

  25. 25

    How to add a row dynamically in a tableLayout in Android

  26. 26

    Unable to add dynamically row in TableLayout Android

  27. 27

    Changing layout in table row using CSS only

  28. 28

    Vuejs Add Table Row Dynamically - Save Row Problem

  29. 29

    Dynamically adding a row to a table using UJS

HotTag

Archive