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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:41:48+00:00 2026-06-06T06:41:48+00:00

I have tableview, where create new rows and set them layout manually. In every

  • 0

I have tableview, where create new rows and set them layout manually. In every row there are 3 main elements: image, textview for title and textview for description. To move them where I want, I use two linear layouts. I want textview for description (named as descView) show text in two lines, but instead – it shows only one. What did I do wrong or what method to call, so view shows text in two lines. Would be perfect if it wraps text by word (not char).

Screenshot of what I have now:

enter image description here

Code of creating new row (‘New’ is Object where I save information (text, image, etc.)):

private TableRow formRow(New item) {

    //prepare table row parameters
    TableRow tr = new TableRow(this);
    tr.setBackgroundResource(R.drawable.results_table_row);
    tr.setVerticalGravity(Gravity.CENTER);
    tr.setTag(item.getTitle());
    tr.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (event.getAction() == MotionEvent.ACTION_UP) {
                v.setBackgroundResource(R.drawable.results_table_row);

            } else if (event.getAction() == MotionEvent.ACTION_DOWN) {
                v.setBackgroundResource(R.drawable.results_table_row_touched);
            }
            return true;
        }
    });


    //create main layout for content
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.HORIZONTAL);

    //add image
    int imageID = Integer.parseInt(item.getPictureSrc());
    ImageView image = new ImageView(this);
    image.setImageResource(imageID);
    image.setPadding(5, 5, 5, 5);
    layout.addView(image);

    //add another layout for title and description
    LinearLayout descLayout = new LinearLayout(this);
    descLayout.setOrientation(LinearLayout.VERTICAL);
    descLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 

    //add title
    TextView titleView = new TextView(this);
    titleView.setText(item.getTitle());
    titleView.setPadding(5, 0, 0, 0);
    titleView.setTextAppearance(this, R.style.TableRowStyle_ChildTitle);
    titleView.setLines(1);
    descLayout.addView(titleView);

    //add description
    TextView descView = new TextView(this);
    descView.setText(item.getDescription());
    descView.setPadding(5, 0, 0, 0);
    descView.setTextAppearance(this, R.style.TableRowStyle_ChildText);
    descView.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    descView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 
    //descView.setEllipsize(TextUtils.TruncateAt.END);
    descView.setLines(2);
    descLayout.addView(descView);

    //add description layout to main layout
    layout.addView(descLayout);

    //finally, add layout to row
    tr.addView(layout);

    return tr;
}
  • 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-06T06:41:49+00:00Added an answer on June 6, 2026 at 6:41 am

    I set max lines to some number and set characters length by calculating character to first dot. So now application know how much information to show and no such bug appear

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

Sidebar

Related Questions

i have a tableview which has image and a text behind, i create the
I have a tableView:didSelectRowAtIndexPath: where I create a ViewController-Instance each time an item is
I have a tableview with large images that fill the cells and the row
I have created sample application that insert 12 rows in tableview.And inserted fine.When after
i have created a tableview in which we can add and delete rows. On
In my root view, I have a tableview with three rows. When I click
I wanted to know if I have to create a new ViewController for each
I am new to iPhone development. I have created a table view in a
I have a custom tableview cell created programmatically that consists of: a background view
I have created a TableView(Grouped Table View). And I can list the items in

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.