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

The Archive Base Latest Questions

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

Here is my code for how i make adding Dynamically TextView in to Table

  • 0

Here is my code for how i make adding Dynamically TextView in to Table Layout using LinearLayout for it.

table_personalData.removeAllViews();
int i=0;
for(String header : headerDetail){
TextView label=new TextView(this);
TextView value=new TextView(this);
label.setTextAppearance(this, R.style.TextBase);
value.setTextAppearance(this, R.style.TextBase);
label.setText(String.format("%s:", header));
value.setText(String.format("%s", lead.data[i]==null?"":lead.data[i]));
i++;
LinearLayout rowview=new LinearLayout(this);
rowview.setOrientation(0);
rowview.setLayoutParams(new  LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
                rowview.addView(label);
                rowview.addView(value);
                table_personalData.addView(rowview);

}

By Above code i get my table layout with dynamically added textview in that .
here i use Liner Layout for added two textview in One Row .

headerDetail is a ArrayList<String> headerDetail
lead.data[i] i used this to get my values for particular label.

All this work fine for me now what my problem is
Now i want to do one thing that is when we click one of the TextView of my LinearLayout i want that TextView in dynamically.
So finally my question is about to get retrieve textview value when we touch or click any textview which is in Linearlayout and LinearLayout is in TableLayout.

Anyone have idea what should i have to do with this .
i also try something like below but i don’t get i can i get TextView Value from below code.

table_personalData.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            for(int i=0;i<table_personalData.getChildCount();i++){


                //CharSequence desc=table_personalData.getChildAt(i).getContentDescription();

                //Log.v("log_tag", "the values are"+ desc);

            }

        }
    });

EDIT:

if you want the Value of TextView when we Touch on that There is Two way that i write Below :

  value.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            TextView txt;
                            txt=(TextView)findViewById(v.getId());
                            String tempEmail;
                            tempEmail=txt.getText().toString().trim();
                            String aEmailList[]={tempEmail};
                            pattern=Pattern.compile(EMAIL_PATTERN);

                            if(validate(tempEmail)){
                                Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                                emailIntent.setType("plain/text");
                                emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,aEmailList ); 
                                startActivity(emailIntent);
                            }else{
                                pattern=Pattern.compile(PHONE_No_PATTERN);
                                if(validate(tempEmail)){
                                    tempEmail=tempEmail.replaceAll("[^\\d]", "");
                                    String uri="tel:" +tempEmail;
                                    Intent mIntent=new Intent(Intent.ACTION_CALL);
                                    mIntent.setData(Uri.parse(uri));
                                    startActivity(mIntent);
                                }else{
                                    //Toast.makeText(LeadDetailActivity.this, "Please Touch on Email or Mo:Number", Toast.LENGTH_SHORT).show();
                                }
                            }
                        }
                    });
  • 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-23T16:58:06+00:00Added an answer on May 23, 2026 at 4:58 pm

    1)Create how many text view u want,but set id for each one,and aslo set same click listener for all

    TextView value1=new TextView(this);
    value1.setid(1);
    value1.setOnClickListener(clickListener);

    TextView value2=new TextView(this);
    value1.setid(2);
    value2.setOnClickListener(clickListener);

    TextView value3=new TextView(this);
    value3.setid(3);
    value3.setOnClickListener(clickListener);

    2)second create one onclick listener,inside this listener u will get all cliks. so based on view id u can dynamically do anything

    OnClickListener clickListener=new OnClickListener() {
    public void onClick(View v) {
    int id=v.getId();
    }
    };

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

Sidebar

Related Questions

I'll make it simple, here's the code I've got. public ActionResult DeleteNonCIStaffUser(int id) {
I'm building a html table dynamically in an ASP.NET code behind file using C#.
There is a weird code here that I need to make work.. can you
I need to make javascript code to swap images with option change. Here is
I'm trying to make things simpler. Here is my code: If Threading.Monitor.TryEnter(syncRoot) Then Try
I'm utilizing the code posted by Jesper Palm here: Make user control display outside
First, to make my job explaining a bit easier, here's some of my code:
I created a my own SortedSet here is the code for adding something to
Here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document()
Ok the error is showing up somewhere in this here code if($error==false) { $query

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.