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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:32:09+00:00 2026-05-26T07:32:09+00:00

I have an adapter where I load my users and one button/textfiled for send

  • 0

I have an adapter where I load my users and one button/textfiled for send invitations. In the adapter I do this:

    @Override
public View getView(int position, View convertView, ViewGroup parent) {                 
    UserAgenda ua = getItem(position);  

    ViewHolder holder;      
    if (convertView == null) {          
        //...         
        convertView.setTag(holder);            
    } else {
        holder = (ViewHolder) convertView.getTag();
    }           

        if(ua.getInvited() != null){
            if(ua.getInvited().equals("true")){
                addTextViewInvited(convertView);//add a textview as the user is invited
            }
            else if(ua.getInvited().equals("false")){
                addButton2Invite(convertView,ua);//add the button to invite
            }
        }       
    return convertView;
}

And on the method of addButton2Invite I send the invitation as:

   private void addButton2Invite(final View convertView, UserAgenda ua) {       

    bt2Invited.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {

            final Button bt2Invited = (Button) convertView.findViewById(R.id.bt2invite);
            final ProgressBar pbar = (ProgressBar) convertView.findViewById(R.id.progress);
            new Thread(){
                @Override
                public void run() { 
                    if(networkWork())
                       ua.setInvited("true"); //Error, NOT PERMITED! ua need to be final.
                };
            }.start();
        }
    });     
}

When the networkWork is OK, I want to set the ua.setInvited("true"); but that is not permited if I dont declare ua as final. But then I cant change its value and next time the adapter enters on getView will find the ua.getInvited() = "false". When I scroll down/up the textview and the button appear on the row.

Any ideas to change the value of the object UserAgenda ua within the onClicklistener?

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-05-26T07:32:10+00:00Added an answer on May 26, 2026 at 7:32 am

    declare the ua final because when at ua.setInvited(true); you are changing a value in object refrenced by ua not the refrence of ua so by setting ua final will not affect your setInvited(true)

    otherwise you have to use click listener by implementing it in your activity class like

    public MyActivity extends Activity implements OnClickListener
    

    and using

    myView.setOnClickListener(this);
    

    and implementing the method of

    public void onClick(View v)
     {
        switch (v.getId()) 
           {
             case R.id.myView:
              //functionality for on click
             break;
            }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found this example Lazy load of images in ListView from Fedor which
Alright so i have been working on this Dynamic load of a spinner from
I have a xml file name list_row.xml, this was load in a listView: <?xml
I have a ListView with a custom Adapter that extends ArrayAdapter. It's a ArrayAdapter
Trying to find the sqlserver adapter for rails on windows. I have tried getting
I have a radio button control adaptor that attempts to render the radio button
When I have a ListActivity and an Adapter how does Android handle a list
I have a load of ADO.NET Entities in my MVC project. I was going
I need an input file stream which would have a bidirectional iterator/adapter. Unfortunately std::ifstream
I have an adapter that uses a CheckedTextView and extends from a SimpleCursorAdapter .

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.