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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:09:43+00:00 2026-05-19T03:09:43+00:00

In plain english, I have a textview, and when I click on it I

  • 0

In plain english, I have a textview, and when I click on it I want it to expand, and when I click on it again, I want it to compress. How can I do this? I’ve tried the below, but it warns on the final line about expander might not be initialized on holderFinal.text.setOnClickListener(expander);

So now the code:


final View.OnClickListener expander = new View.OnClickListener() {
@Override
  public void onClick(View v) {
    holderFinal.text.setText(textData);
    holderFinal.text.setOnClickListener( new View.OnClickListener() {       
    @Override
      public void onClick(View v) {                                    
        holderFinal.text.setText(shortText);
        holderFinal.text.setOnClickListener(expander);
      }
    });
 }
};
  • 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-19T03:09:43+00:00Added an answer on May 19, 2026 at 3:09 am

    No need to use nested overrides if you can use the tag property:

    const int COLLAPSED = 0;
    const int EXPANDED = 1;
    // set initial value(s) somewhere
    holderFinal.setTag(COLLAPSED);
    holderFinal.text.setText(shortText);
    
    
    holderFinal.text.setOnClickListener( new View.OnClickListener() {       
    @Override
      public void onClick(View v) {
        int i = (int)holderFinal.getTag();
        if (i == EXPANDED)
        {
          holderFinal.setTag(COLLAPSED);
          holderFinal.text.setText(shortText);
        }
        else
        {
          holderFinal.setTag(EXPANDED);
          holderFinal.text.setText(textData);
        }
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in plain english can you please explain to me what does this line mean:
In plain English this is the jQuery functionality i'm after: I need to get
The code below allows the user to enter in a phrase in plain English,
Can someone please explain in plain English how to calculate it? I know that
I have 3 tables that I have tried to lay out below. I am
i have been going through the backbone js official documentations, but i can't seem
Does Ruby have a plain-English keyword for exclusive or, like they have and and
Possible Duplicate: Plain English explanation of Big O I have always struggled to calculate
I want to have a drop down on a form that shows in plain
Can anyone break it down in plain English the performance difference between using temp

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.