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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:14:24+00:00 2026-05-31T16:14:24+00:00

i would like you to help me. I want to create dynamicly table (screenshot).

  • 0

i would like you to help me.
I want to create dynamicly table (screenshot). I created it via code below:

    TableLayout tl = (TableLayout) findViewById(R.id.main_table);

    FOR. 1-300.........
    TableRow tr_head = new TableRow(this);
    tr_head.setId(10);
    tr_head.setBackgroundColor(Color.CYAN);
    tr_head.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
    RelativeLayout rl = new RelativeLayout(this);
    rl.setId(20);


    ImageButton xyz = new ImageButton(this);
    xyz.setId(21);
    xyz.setPadding(5, 5, 5, 5);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT );
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 20 );
    rl.addView(xyz,params); 

    tr_head.addView(rl);
    tl.addView(tr_head, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 
    END OF FOR.......  

Via similar code i nicely create 2 types of items one for category(3 child views) and one for category item(10 child views).
Then i use code bellow to assign onclick listener for buttons and whole items.:

int count = tl.getChildCount();
    for(int i = 0; i < count; i++){
        TableRow v = (TableRow)tl.getChildAt(i);

        if(v.getChildAt(0) instanceof RelativeLayout){
            RelativeLayout relativ = (RelativeLayout)v.getChildAt(0);

        if(relativ.getChildCount()>5)
            relativ.setOnClickListener(new MyClickListener());
                     ...........

But when i want to create table which contains 300 items, it takes 30 sec. to render this view on emulator. It is really very slow. So i would like to ask you how to render this view. Some example or tutorial will be very helpfull.

Many Thanks in advance.

I want to create this

  • 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-31T16:14:25+00:00Added an answer on May 31, 2026 at 4:14 pm

    Android is very slow at having many Views in memory. To work around this I would recommend using the default Andoird ListView with a custom ListAdapter.

    The Views are created on the fly when the user scrolls the list, so only the currently visible Views have to be in memory.

    This example uses a CursorAdapter, but you can also use an ArrayAdapter.

    private class ExtendCursorAdapter extends CursorAdapter {
    
        public ExtendCursorAdapter(Context context, Cursor c) {
            super(context, c);
        }
    
        @Override
        public int getItemViewType(int position) {
            if (position == 0) { //Determine if it's a category or an item
                return 0; // category
            } else {
                return 1; // item
            }
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (getItemViewType(position) == 0) {
                View v;
                if (convertView != null)
                    v = convertView;
                else
                    v = inflater.inflate(R.id.listcategory);
                // Set title, ...
                return v;
            } else{
                // the same for the item
            }
        }
    }
    

    An additional performance increase comes from the usage of convertView. While scrolling you don’t need to create any additional Views because Android reuses the ones which come out of sight. You just have to make sure to reset all data of convertView.

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

Sidebar

Related Questions

I would like to help out my girlfriend - she needs the specific count
I'm new to the site. would like some help if at all possible. I
i would like a simple help... i have a url like this: example.com/profile.php?id= &
I would really like your help in knowing the procedure to delete a .3gp
I would like to as some help. Is there a certain method in javascript/jquery
I would like information on algorithms that can help identify commonality and differences between
I would like to know how to generate help files for an applescript studio
I would like to know if there are any tools that can help me
Could somebody help me.I would like to get substring of string by ant.For example
I have the following code to encrypt a value (listed below). Now I would

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.