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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:12:10+00:00 2026-06-02T07:12:10+00:00

Im populating a ListView using the following: list = (ListView) findViewById(R.id.historylist); ArrayList<HashMap<String, String>> mylist

  • 0

Im populating a ListView using the following:

list = (ListView) findViewById(R.id.historylist);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
String[] titles = new String[]{"transactionID","date","description","redeem","reward","status"};

try{

for(int i=0;i<rows.length();i++){
    map = new HashMap<String, String>();
    for(int n=0;n<allRows.getJSONArray(i).length();n++){
        map.put(titles[n], allRows.getJSONArray(i).getString(n));
    }
    mylist.add(map);
}

mSchedule = new SimpleAdapter(
    History.this,
    mylist,
    R.layout.history_row,
    titles,
    new int[] {R.id.textView0, R.id.textView1, R.id.textView2, R.id.textView3, R.id.textView4, R.id.textView5});

list.setAdapter(mSchedule);

for(int i=0; i<mylist.size(); i++)
    if(((Map<String, String>) mSchedule.getItem(i)).get("status").equals("0"))
        try{
            // SET BACKGROUND COLOR OF ROW
        }catch(Exception e){
            Log.e("AAA Error getting ListView row", e.toString());
        }

}catch(Exception e){
Log.e("Error Creating ListView", e.toString());
}

I’d like to change the background color of any ListView row which contains a status of “0”.

Any ideas?

NEW: Here’s the updated code – much nicer (Except for the part where I have to manually chop characters from the JSONArray.. eww..)

private void showListView(JSONArray rows, JSONArray totals){

    list = (ListView) findViewById(android.R.id.list);
    ArrayList<String[]> rowValues = null;
    String[] r = null;

    try{
        rowValues = new ArrayList<String[]>();
        for (int i=0;i<rows.length();i++){

            r = rows.get(i).toString().replaceAll("\\[\"", "").replaceAll("\"\\]", "").split("\",\"");
            rowValues.add(r);
        }

        mba = new MyBaseAdapter(this, rowValues);
        list.setAdapter(mba);

    }catch(Exception e){
        Log.e("showListView() ERROR", e.toString());
    }
}
  • 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-02T07:12:11+00:00Added an answer on June 2, 2026 at 7:12 am

    I don’t think you can. The only way to achieve what you are saying is creating a new class extending BaseAdapter and changing the background color of your view on the getView() method in that class

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

Sidebar

Related Questions

1.) My main.xml contains : <ListView android:id="@+id/lsym" android:layout_width="wrap_content" android:layout_height="wrap_content"/> 2.) After populating the list,
I'm populating a listview with a list of databases on a selected SQL instance,
I am populating a Listview (list.xml) with a textview (list_row.xml). I need to add
I am populating a list of friends using an ajax call to a php
So I've got a ListView (using a ListActivity ) that I'm populating from a
In my application, to populating a ListView i am using custom adapter, because one
Following the Android sample for populating a ListView , I query an array from
I'm populating a ListView with items and add images from an ImageList (in the
I have a ListView that I am populating with items from an ObservableCollection .
I have a listview that I'm populating with data and I'm trying to get

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.