Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8692797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:23:38+00:00 2026-06-13T00:23:38+00:00

Edit: as Blumer pointed out, I was not adding the items to the table,

  • 0

Edit: as Blumer pointed out, I was not adding the items to the table, so that this question appeared just because I was careless and I didn’t see my mistake.

I am trying to create a dynamic TableLayout, as I have to receive results from the server and add rows based on the results, but the table is not updating. (Also, the TableLayout already has 1 initial row, the header row).

This is my code:

    Room[] rooms = State.rooms;
    TableLayout tblBookDetails = (TableLayout) findViewById(R.id.tblbookdetails);
    for(int i = 0; i < rooms.length; i++) {
        TableRow tr = new TableRow(this);
        tr.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        LayoutParams layout_wrapwrap = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layout_wrapwrap.rightMargin = 10; //TODO: Convert into DP
        Resources res = getResources();

        TextView txt1 = new TextView(this);
        txt1.setLayoutParams(layout_wrapwrap);
        txt1.setTextColor(res.getColor(android.R.color.black));
        txt1.setText(rooms[i].name);
        TextView txt2 = new TextView(this);
        txt2.setLayoutParams(layout_wrapwrap);
        txt2.setTextColor(getResources().getColor(android.R.color.black));
        txt2.setText(rooms[i].price + " " + rooms[i].currency);
        EditText edit1 = new EditText(this);
        edit1.setLayoutParams(layout_wrapwrap);
        //Must use deprecated method, since support library does not provide for this.
        edit1.setBackgroundDrawable(res.getDrawable(android.R.drawable.edit_text));
        edit1.setEms(3);
        edit1.setInputType(InputType.TYPE_CLASS_NUMBER);
        EditText edit2 = new EditText(this);
        edit2.setLayoutParams(layout_wrapwrap);
        //Must use deprecated method, since support library does not provide for this.
        edit2.setBackgroundDrawable(res.getDrawable(android.R.drawable.edit_text));
        edit2.setEms(3);
        edit2.setInputType(InputType.TYPE_CLASS_NUMBER);
        Spinner spinner = new Spinner(this);
        layout_wrapwrap.rightMargin = 0;
        spinner.setLayoutParams(layout_wrapwrap);

        Integer[] numbers = new Integer[rooms[i].count];
        for(int j = 0; j < numbers.length; j++) {
            numbers[j] = i + 1;
        }
        ArrayAdapter<Integer> adapter = new ArrayAdapter<Integer>(
                BookActivity.this, R.layout.spinner_textview, numbers);
        spinner.setAdapter(adapter);
        tblBookDetails.addView(tr);
    }
    //Another exquisite beauty of Java.
    Log.d("USR", Integer.valueOf(tblBookDetails.getChildCount()).toString());
    tblBookDetails.invalidate();
    tblBookDetails.refreshDrawableState();

To prevent any confusion, the Room[] array is just a simple property-holder class.
This code looks enormously convoluted, and the table is not updating. I’ve searched quite a bit on the Internet, and I could not find any solution for this problem.

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:23:39+00:00Added an answer on June 13, 2026 at 12:23 am

    I see where you add tr to tblBookDetails, but I don’t see anywhere where you put txt1, txt2, edit1, etc. in tr. Try adding those views to the row, and I think that should get you there, because right now you appear to be adding the TableRow, but there’s nothing in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT : It turned out that this can only be done through an external
EDIT: I rephrased the question because I have not explained well. Let's see if
Edit: to clarify - i just found out that it is really easy to
-- EDIT: I just realized that the right answer to this is maybe a
Edit: This question has been moved to Getting an error from Xcode that is
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
Edit (updated question) I have a simple C program: // it is not important
EDIT I have check the execution and found that the error is not (yet)
Edit 1 Updated to make the enum not an argument to the method... Question
EDIT : I've gotten the famous question badge with this question, so I figured

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.