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 6578061

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:43:19+00:00 2026-05-25T15:43:19+00:00

I have the next layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=horizontal android:layout_width=fill_parent android:layout_height=wrap_content> <ImageView

  • 0

I have the next layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/foto"
        android:scaleType="fitCenter"
        android:layout_width="70dp"
        android:layout_height="70dp"/>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:paddingLeft="10dp"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="fill_parent"
            android:id="@+id/nombre"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:textColor="#ffffff"
            android:textSize="16sp" />
        <TextView
            android:layout_width="fill_parent"
            android:id="@+id/posicion"
            android:textColor="#ffffff"
            android:layout_height="wrap_content"/>
    </LinearLayout>
</LinearLayout>

And I would like to set this layout to a TableRow programmatically.
Any idea?

Thanks.

  • 0 0 Answers
  • 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-25T15:43:20+00:00Added an answer on May 25, 2026 at 3:43 pm

    As Cristian suggested, using LayoutInflater solved my problem.
    This is the code for my activity:

    public class SeleccionarJugador extends Activity {
    
    private TableLayout mTablaJugadores;
    
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
    
        // Se establece el layout
        setContentView(R.layout.jugadores);
    
        // Se recupera la tabla donde se insertán los jugadores de ambos equipos
        mTablaJugadores = (TableLayout) findViewById(R.id.tabla_jugadores);
        LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
        TableRow fila = new TableRow(this);
        View v = inflater.inflate(R.layout.fila_seleccionar_jugadores,null);
        TextView dorsal = (TextView) v.findViewById(R.id.dorsal);
        dorsal.setText(String.valueOf(11));
        TextView nombre = (TextView) v.findViewById(R.id.nombre);
        nombre.setText("Pepe");
        TextView posicion = (TextView) v.findViewById(R.id.posicion);
        posicion.setText("Lateral");
        fila.addView(v);
        mTablaJugadores.addView(fila);
    
    }
    

    I “inflate” one View with the layout which I would like to insert into each row, and I take the components inside the Layout, manipulate them, and then insert the View into the row.
    Finally, just I have to insert the row into the Table and That’s it!.

    Thanks a lot.

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

Sidebar

Related Questions

I use the following main.xml for my app. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
I have created a custom Button as follows. file : buttoncontrol.xml <?xml version=1.0 encoding=utf-8?>
I have three xml layout pages, 1.welcome screen (with next >> button) and clicking
I have two Android projects, a 'library project' containing a custom layout, and an
I have been having problems creating a relative layout in XML for a list
I have a horizontal LinearLayout. This LinearLayout has a checkbox next to another LinearLayout.
I'm going to start of by noting that I have next to no python
I have the next function: function setImagesWidth(id,width) { var images = document.getElementById(id).getElementsByTagName(img); for(var i
In my fieldset I have labels next (side) to my textboxes, but for some
How could I best implement the following scenario? I have a Next Period... button

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.