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

The Archive Base Latest Questions

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

I created new TextViews in my GUI dynamically and I collected them in an

  • 0

I created new TextViews in my GUI dynamically and I collected them in an array of TextViews, but I can’t set up OnClickListeners because of that (they’re inside of an array)…

So what I want to do now is evaluate if the TextView is clicked and handle that event, but I’m not sure how to do so…

If I’m not being to clear, please tell so I can write down the problem with all the details…

Thanks!

  • 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-13T08:48:42+00:00Added an answer on June 13, 2026 at 8:48 am

    Even when you are creating rows dynamically you still have a reference to the TextView. Simply add the OnClickListener to this reference, like this:

    TextView tv1 = new TextView(this);
    tv1.setText(string);
    tv1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    tv1.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // Do something
        }
    });
    row.addView(tv1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a new cordova project on XCODE, I have some files that I
I created a new repository on github. I selected one of the options that
I have created a dynamic array of buttons that come from sqllite database. For
I need to refresh TextViews every 5 seconds, I have created TimerTask( and set
I have a horizontalscrollview containing many textviews that are added dynamically. When I press
I've created new db via phpMyAdmin and while editing db privilages clicked delete localhost
i have one doubt,i have created new project in eclipse with android 2.3.1 and
Lets go from the start Created New Xcode project,opened interface builder dragged one NSButton
I have a new Codeblocks install with mingw32 compiler. Created new c++ console project
i'm using eclipse platform and window builder pro within. I've already created new project

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.