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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:35:44+00:00 2026-06-15T23:35:44+00:00

I have a general scenario, but couldn’t make out how to handle it. I

  • 0

I have a general scenario, but couldn’t make out how to handle it.

I have a ListView with each item having different clickable views. Of which 1 is add as friend button beside the user name in the item.

So, in the ListViewAdapter’s getView() i implemented onClick for this button this way.

onClick(){

//make the button invisible, for UX
//change the value of is_friend = 1, in the Adapter ArrayList, which will be helpful when listView is scrolled and getView is called again, to make it visible or invisible.
//Send the info to the server as an AsyncTask
}

This works fine.

Problem:

instead of clicking the add as friend button, I can click the user name go to his profile and click the add as friend button in that Activity.

Now when i comeback to the ListView, the add as friend button is still visible, because the adapter ArrayList has old data taken from server and i am not even changing them.

I thought of StartActivityForResult when user name is clicked. But i might not comeback to the ListView as soon as i click add as friend, there are lot of other actions on a user’s profile.

A familiar case easily handled by many apps. Any idea on how this is done?

Thank You

EDIT:

Though the answers given below work. They are not the best way to do.

So, a better way might be to make a call to a static method of the listViewAdapter to update that value only in its ArrayList??

  • 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-15T23:35:44+00:00Added an answer on June 15, 2026 at 11:35 pm

    The comment of gsingh2011 is valid. However, I am guessing that your remark will be something like “I populate the ArrayList by querying the server and I don’t want to do that to often”.

    More generally speaking, the comment of gsingh can be translated to this: you should base your adapter and ‘ViewProfileActivity’ on the same data. You can do this by sharing the ArrayList between the two (as a static, or a public member or whatever you want). When you then change something from your ‘ViewProfileActivity’, your ListView will automatically update once you switch back to it (because getView() will be called on its adapter again, which will generate a view based on the new data).

    The text above is an answer to your question, but let me just add some other remarks:

    • you say you are sending info to a server in an asynctask. You should change this to using an (Intent)Service for that. You don’t have any guarantees that your data will be fully sent when your Activity is put in the background. If you delegate this server synchronization to a Service, it will make sure your process is kept around long enough for your send to finish.
    • once you have that service, that would be a nice place to put your “shared data” as discussed above. You could also use a small database for that and let the service only handle the synchronization between your local database and the remote server. Then you have something that is beginning to look like a REST implementation, where your device is caching remote data locally, but in the end is only visualizing the state of the remote server. You can look up an excellent google i/o presentation on dealing with REST servers. This presentation is also nice if you are not interested in the REST part, because (maybe more importantly) it shows you what things you have to take into account when you want to have guarantee of successful persistence of data.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In general, I have the following scenario: Fetch product and its related data from
I have a general database structure question. In my scenario I happen to be
I have a general JavaScript question. I'll give you my scenario and then ask
This question is specific to Erlang, but may have general implications to other IO
I have a general question on the class definition and its use..THe below code
I have a general purpose Utility dll file used in my WPF program. The
I have a general question about interpreters of functional languages: Are there actually any
i have a general question : i'd like to develop a facebook application using
I have a general question about the new Django 1.3 static file framework. I
I have a general OOP question. If I have the following classes in C#

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.