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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:56:02+00:00 2026-06-07T06:56:02+00:00

I want to add a ImageView in TableLayout. I do all things, but it

  • 0

I want to add a ImageView in TableLayout. I do all things, but it isn’t shown anything. How can I fix it?

This is my code:

public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.buddy_list);

   TableLayout buddy_list_layout = (TableLayout)findViewById(R.id.buddy_list_layout);

    TableRow tableRow = new TableRow(this);
    TableLayout.LayoutParams layoutParams1 = new TableLayout.LayoutParams(
    TableLayout.LayoutParams.FILL_PARENT,
        50);

    ImageView imageView = new ImageView(this);
    imageView.setImageResource(R.drawable.troll_logo);
    TableLayout.LayoutParams layoutParams2 = new TableLayout.LayoutParams(50, 50);
    tableRow.addView(imageView, layoutParams2);
    buddy_list_layout.addView(tableRow, layoutParams1);
} // end -> method -> onCreate
  • 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-07T06:56:04+00:00Added an answer on June 7, 2026 at 6:56 am

    Try using a pre-defined xml layout for rows, like someone suggests here: https://stackoverflow.com/a/8679835/375929 (you probably don’t want it completely dynamic, your rows are most likely similar, you just need to add them dynamically) It will save you the effort of LayoutParams stuff programmatically.

    But yeah, your problem is probably using the wrong LayoutParams class, as matt5784 says.

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

Sidebar

Related Questions

I want to add rows to a tablelayout dynamically. This is my code. TableRow
I want to add ImageView to FrameLayout with Gravity or margins. but FramLayout and
I want add my custom sidebar next right column all page. Please check this
I have a code on ICS for tablets. I want to add a Imageview
I want to add an image onto another image. But I know that imageview
with this code, i want to add an image at the place the user
I want add UIGestureRecognizerDelegate to UIWebView,but failed. if [self.view addsubView:webView]; So UIWebView is ok,but
I want add new Feed item on entity persist and update. I write this
I want to add an unknown number of ImageView views to my layout with
I want to add a custom Dialog, but I have problems creating a xml

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.