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

  • Home
  • SEARCH
  • 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 1042875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:34:40+00:00 2026-05-16T15:34:40+00:00

I have a general question regarding Android’s separation of layouts into layout.xml files: My

  • 0

I have a general question regarding Android’s separation of layouts into layout.xml files:

My app needs to display a table where the number of rows and columns varies at runtime.
So far I did the layout up to the TableView in the corresponding layout/….xml file and then I added TableRow-s and cells (TextView) to the table at runtime as needed. The drawback of adding rows and cell programmatically is, that one can not really change the design later (e.g. changing colors or margins for the cells) without later code modification.

What I would this like to do is to add a single row to the table and a single cell to the row in the layout file and then use these as a “pattern” or templates to generate all the actual table’s rows and cells. This would allow to specify colors and other parameters in the layout.xml file (and thus also be able to change them later without code change) but still allow for an arbitrary number of columns and cells.

However, I found no “copy”-constructor or “duplicate”-method in Views. How can one achieve this? What is the suggested method to create lists or tables from a single “example” or template element? Or is there another method to achieve what I want?

Hope I could make myself clear…
Michael

  • 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-05-16T15:34:41+00:00Added an answer on May 16, 2026 at 3:34 pm

    Generally with a TableLayout or ListView, you create a layout xml file for the row and then inflate it for each instance programmatically.

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
    TableRow rowView = (TableRow)inflater.inflate(R.layout.my_row, null);
    table.addRow(rowView);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a general question - regarding testing of values, I have run into
I have a very general question regarding the use of LINQ vs SQL to
I have a simple, general question regarding a real small issue that bothers me:
I have a question regarding an ArrayList of Integers, or primitive types in general.
I have general question regarding the use of pointers vs. references in this particular
I have a general question regarding UITableViews. here is my situation. I have a
I have a general question regarding the syntax of throwing an object. Consider: #include
I have a rather general question regarding JavaScript and local variables. My question is
I have a general question regarding bundles, libraries and custom frameworks on the iOS.
I have a relatively general question regarding SAX. I understand how it works, and

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.