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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:23:06+00:00 2026-05-27T19:23:06+00:00

what will i do to add this layout into main.xml . this class file

  • 0

what will i do to add this layout into main.xml . this class file is sperate from main activity class. should i need to call this class into main activity class for add this dynamic tablelayout. and tell me how to add this class into main activity class

import android.R.color;
import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextWatcher;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.SimpleAdapter.ViewBinder;
import android.widget.TableRow.LayoutParams;

public class TestGridActivity extends Activity implements View.OnClickListener{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);

        TableLayout layout = new TableLayout (this);
        layout.setLayoutParams( new TableLayout.LayoutParams(85,85) );

        layout.setPadding(8,8,8,8);

        for (int f=0; f<=6; f++) {

            TableRow tr = new TableRow(this);

           tr.setBackgroundColor(Color.BLACK);
           tr.setPadding(0,0, 0,2 );

           TableRow.LayoutParams llp = new        TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
           llp.setMargins(0, 0, 2, 0);//2px right-margin

           //New Cell

           for (int c=0; c<=288; c++) {

               LinearLayout cell = new LinearLayout(this);
               cell.setBackgroundColor(Color.WHITE);
               cell.setLayoutParams(llp);//2px border on the right for the cell

                TextView b = new TextView (this);
                b.setText("Sample");
                b.setTextSize(10.0f);
                    b.setHeight(60);
                    b.setWidth(70);
                b.setPadding(0, 0, 4, 0);

                cell.addView(b);
                tr.addView(cell);

           } // for
            layout.addView(tr);
        } // for

        super.setContentView(layout);
    } // ()

    public void onClick(View view) {
        ((TextView) view).setText("*");
        ((TextView) view).setEnabled(false);
    }
 } // class

what should i do to pass this tablelayout into main.xml layout

  • 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-27T19:23:07+00:00Added an answer on May 27, 2026 at 7:23 pm

    set main.xml a contentview and add your dynamic tablelayout as a view
    to the layout declared in main. xml.

    so your code for onCreate() will be like the following

    public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
    LinearLayout ll = (LinearLayout) findViewById(R.id.add_layout);
    
                TableLayout layout = new TableLayout (this);
                layout.setLayoutParams( new TableLayout.LayoutParams(85,85) );
    
                layout.setPadding(8,8,8,8);
    
                for (int f=0; f<=6; f++) {
    
                    TableRow tr = new TableRow(this);
    
                   tr.setBackgroundColor(Color.BLACK);
                   tr.setPadding(0,0, 0,2 );
    
                   TableRow.LayoutParams llp = new        
                           TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
                   llp.setMargins(0, 0, 2, 0);//2px right-margin
    
                   //New Cell
    
                   for (int c=0; c<=288; c++) {
    
                       LinearLayout cell = new LinearLayout(this);
                       cell.setBackgroundColor(Color.WHITE);
                       cell.setLayoutParams(llp);//2px border on the right for the cell
    
                        TextView b = new TextView (this);
                        b.setText("Sample");
                        b.setTextSize(10.0f);
                            b.setHeight(60);
                            b.setWidth(70);
                        b.setPadding(0, 0, 4, 0);
    
                        cell.addView(b);
                        tr.addView(cell);
    
                   } // for
                    layout.addView(tr);
                } // for
                ll.addView(layout);
    //          super.setContentView(layout);
            } // ()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I need to extend the CListControl class in C++/MFC, which will add several
Using Your Ruby Gem(s) You will need to add /home/username/ruby/gems to the include path.
Background: We have app a, b, and plan to add more apps into this
The following code will add the categories selector widget to the WordPress Page editor
We are making a game which will add a level editor feature soon. We
I want to make a table in SqlServer that will add, on insert, a
I have a form a user can enter their name, then it will add
I have a button that, when pressed, will add a new HTML row. Within
I'm working on a module that, among other things, will add some generic 'finder'
when will i add Advanced data grid in my project then it shows eror

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.