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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:29:31+00:00 2026-05-25T23:29:31+00:00

Hello folkes I have this little problem for which I cannot find a suitable

  • 0

Hello folkes I have this little problem for which I cannot find a suitable answer looking around the web and on these forums. Please don’t direct me to articles in which people have requested list view text color changes at run time, as I read lots of them and not found one to help me out.

I have a simple ListView that displays an array of String objects via the use of a ListAdapter.

I need to update some of ListView Strings at run time, based on their contents. Using a global reference to the list adapter used in the lists views creation I can get the contents of each list view String using following code below.

However, in addition to retrieval I’d like to be able to modify each string in turn, then put it back in the same index position and have the list view reflect the changes. How?

        for (int x = 0; x <= listAdapter.getCount();x++)
        {
            Object o = this.listAdapter.getItem(x);

            if (o.getClass().getSimpleName().equals("String"))
            {
                String s = (String) o;

                  s = modifyString(s);

                //s is the string I want to modify then put back in the same place.

            }//end if
        }//end for
  • 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-25T23:29:31+00:00Added an answer on May 25, 2026 at 11:29 pm

    As far as I know you cannot change the items in an Adapter – unless you are using a custom Adapter (by extending a BaseAdapter etc…)

    So, I think you will have to:

    1. make sure you Adapter’s constructor takes in the data structure that holds your strings
    2. make sure your data structure is global
    3. make the changes in that data structure whenever you need to
    4. call myAdapter.notifyDataSetChanged();

    This will tell adapter that there were changes done in the list and listview should be recreated.

    And after your listview is renewed you can even take the user back to the index by:

    list.setSelection(positionWhereTheUserClicked);
    

    I hope this helps, let me know if you need more code references.

    Here is some code

    private ArrayList<String> results = new ArrayList<String>();  //global
    private BaseAdapter searchAdapter = new BaseAdapter (results, this);  //global
    
    private void updateResults(final ArrayList<String> updatedList){
        results = updatedList;
        final ListView list = (ListView)findViewById(R.id.search_results);
        list.setAdapter(searchAdapter);
        list.setOnItemClickListener(new ListView.OnItemClickListener(){
            // implementation of what happens when you click on an item //
        });
        searchAdapter.notifyDataSetChanged();
    }
    

    This code works just fine on my end, I hope it helps.

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

Sidebar

Related Questions

Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello I have a problem with this http://jsfiddle.net/E7dGA/1/ When the script starts and you
Hello I have two text inputs which get their values from a datepicker. What
Hello good morning everyone, i have an iphone app which is still in development
Hello I have strange problem. I configured spring + hibernate. I`m using annotation configuration
Hello I am new to the Objective C and I have a problem. I
Hello I have this query... if (isset($_REQUEST['deletePost'])) { $q = $dbc -> prepare(DELETE FROM
Hello I have a form which has two buttons. In the form validation (onsubmit
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
Hello can anybody solve this please I'm creating the object in the action class

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.