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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:48:53+00:00 2026-06-02T01:48:53+00:00

I have a list populated from a sqlite database with data values ranging from

  • 0

I have a list populated from a sqlite database with data values ranging from -1 to 1. Is there any way to set the background color for the negative items to red and the positive items to green? A similar effect could be had by adding a green up arrow to the item view for positive and a red down arrow image for negative values. Another example might be a to-do list with items color coded by a priority value. In ios this would occur in cellforrowat indexpath and on windows phone/silverlight it would be done by binding a dependency property to the data. Can this be achieved with Android?

  • 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-02T01:48:54+00:00Added an answer on June 2, 2026 at 1:48 am

    Try like this.. in getView method

       @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.rowlayout, parent, false);
        TextView textView = (TextView) rowView.findViewById(R.id.label);
         ImageView imageview= (ImageView) rowView.findViewById(R.id.img);
        textView.setText(values[position]);
        String s = values[position];
        if (s.startsWith("-")) {
            imageView.setImageResource(R.drawable.uparrow);
       //or set background colour of those views here..
        } else {
            imageView.setImageResource(R.drawable.downarrow);
        }
    
    
        return rowView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListFragment populated from a Cursor. I have the list background set
I currently have a dropdown list being populated with values from a database. I
I have a list view populated by an adapter reading from SQLite database. When
I have a ListView populated by a series of data from an SQLite Database.
I have a select list which is being populated using the values from a
I have made the following code to retrive data from SQLite database. public Cursor
I have a ListView with custom adapter which is populated from local sqlite database.
I have a list view, the contain is populated from a database. And I
I have a listview which loads its data from sqlite database. Each row in
i have a drop down list which is populated dynamically from database table i.e

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.