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 7447243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:33:01+00:00 2026-05-29T12:33:01+00:00

Update: I am sorry i pasted in list.xml twice by mistake, my question is

  • 0

Update: I am sorry i pasted in list.xml twice by mistake, my question is now correct!…

I created a class which extends ArrayAdapter, in which I override getView, and in there I capture controls in my row.xml, and setText on them appropiately with my values. This all works fine, I got no problem here.

What I then tried to do is have my output in tabular format, so I can span columns etc and get them all aligned as I wish. Here start my problem.

So I lave my two xml files, one for my list, and one for the row. In the list I define a TableLayout, with nothing in it except my ListView. Not how I set my stretchColumns property? Then in row.xml, I just define a TableRow, so I would expect to get a load of TableRows tags created inbetween the TableLayout start and end tags, and everything will turn out good.

Well it does work in the sense that I can see teh results, HOWEVER all of the TableRows are not aligned with the rest of thd table, or other rows. They just all get sixed to fit there own contents, and seems they are not properly a part of my TableLayout at all.

If I create by hand the xml I would EXPECT to be inflated in my custom adapter, and put it between the TableLayout tags (and remove the ListView) everything displays perfectly, columns aligned etc.

Perhaps I am doing something wrong, or perhaps I should not be using a TableLayout this way and ought to be doing things a different way.

Really appreciate any helps with this, been stuck puzzled on if for ages.

this is row.xml

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/tvQty"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:text="QTY"
        android:textSize="12dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/tvPartName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:paddingLeft="10dip"
        android:text="Part desererregre"
        android:textSize="12dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/tvPartCode"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:paddingLeft="10dip"
        android:text="PART CODE"
        android:textSize="12dp"
        android:textStyle="bold" />
</TableRow>

this is my list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <Button
        android:id="@+id/addCallPart"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onClick"
        android:text="Button" />

    <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="5dip"
        android:paddingRight="5dip"
        android:stretchColumns="1" >

        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/hello" />
    </TableLayout>

    <TextView
        android:id="@id/android:empty"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="There are no records." />

</LinearLayout>

here is my code, this all works ok, but i include it to make the question clearer

public class CallPartAdapter extends ArrayAdapter<CallPart> {
    private final Context context;
    private final List<CallPart> values;

    public CallPartAdapter(Context context, List<CallPart> values) {
        super(context, R.layout.row, values);
        this.context = context;
        this.values = values;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.row, parent, false);

        TextView textView1 = (TextView) rowView.findViewById(R.id.tvQty);
        TextView textView2 = (TextView) rowView.findViewById(R.id.tvPartName);
        TextView textView3 = (TextView) rowView.findViewById(R.id.tvPartCode);

        textView1.setText(Integer.toString(values.get(position).Qty));
        textView2.setText(values.get(position).PartName);
        textView3.setText(values.get(position).PartCode);       

        return rowView;
    }   
}
  • 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-29T12:33:02+00:00Added an answer on May 29, 2026 at 12:33 pm

    You can’t use TableLayout that way. Well, let me rephrase… you can but you won’t get the results you desire. You’ve essentially got a TableLayout with a single row: the ListView. So none of the items in your ListView will receive any of the layout benefit of being in a TableLayout. They are simply ListView items.

    You have two real options:

    1. Dynamically add your rows to the TableLayout. You can still use an adapter, but it won’t buy you much, since you’ll simply be using it as a List.
    2. Modify your row layout to provide a TableLayout style of layout and stick with the ListView parent.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for the double post, I will update this question if I can't get
UPDATE: sorry my IE 9 was'nt configured well: it should've been set so that
UPDATE Turns out I'm just tired. There isn't any problem here sorry for wasting
update: I mistyped 2 variables...so embarrassing. thanks everyone for the effort! sorry i find
[Updated, sorry about the change but now to the real problem] I cannot include
Update : This is no longer an issue from C# 6, which has introduced
I'm trying to update a text box from a class called 'hex' to the
UPDATE : My original question was invalid because I was misreading the MySql logs.
newbie here, sorry if this is an obvious question, and sorry for my English.
sorry for my English. I previously posted this question as: Multiple ViewModels request same

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.