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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:54:16+00:00 2026-05-25T21:54:16+00:00

I’m working on a debt tracking app, and have need for a progress bar

  • 0

I’m working on a debt tracking app, and have need for a progress bar that as the current debt goes down, the progress goes up. The only way I can think to do this would be to fudge the numbers around so that the progress bar MAX is set to 0, and then change the starting debt to be a negitive number, as follows

ProgressBar.setMax(0);

Integer startingdebt = -1000;  // 1000$ owed
ProgressBar.setProgress(currentlyowed);  //say, -500

so you start with -1000, and add 500$ to it if you paid it. I don’t know if this would work though, because I’m sure the progressbar control has a set minimum of 0 already, so you can’t set max the same…is there a way to do this?

Edit: Thanks for the answers guys, but I found an easier way:
to share with others, here’s my final code block:

    double startingamount = (this.c.getDouble(this.c.getColumnIndex(DbAdapter.KEY_STARTINGAMOUNT)));
    double currentamount = (this.c.getDouble(this.c.getColumnIndex(DbAdapter.KEY_CURRENTAMOUNT)));
    currentdebt.setText(formatter.format(currentamount));
    double progresspaid = new Double(startingamount-currentamount);
    double progresspercentage = new Double((progresspaid / startingamount)*100);
    int progresspercent = (int)progresspercentage;
    progressbar.setText(Integer.toString(progresspercent)+"%");
    progressbar.setMax(100);
    progressbar.setProgress(progresspercent);

the key was to get a variable that subtracts the current amount from the starting amount, and then divides that by the starting amount.

double progresspaid = new Double(startingamount-currentamount);
double progresspercentage = new Double((progresspaid / startingamount)*100);

Thanks again though, I really appreciate people helping me learn Java and android development, I’m a VB.net developer so some of this is still foreign to me.

  • 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-25T21:54:17+00:00Added an answer on May 25, 2026 at 9:54 pm

    While this may not be ideal (I don’t use Android and avoid UI coding ;-), the numbers and percentages can be calculated with a little math — it may be problematic if the raw value is itself displayed on the progress bar.

    The percent going from 0 … 100 is:

    percent = (current - min) / (max - min)
    

    (When min = 0, this is trivially percent = current / max.)

    And the percent going from 100 to 0 is:

    percentReverse = 100 - percent
    

    or, expanded:

    percentReverse = 100 - ((current - min) / (max - min))
    

    Example, current = -800, max = 0, min = -1000:

    percent = (-800 - -1000) / (0 - -1000) = 200/1000 = 20 (% done)
    percentReverse = 100 - 20 = 80 (% left)
    

    Another example, current = 0, max = 2000, min = -1000:

    percent = (0 - -1000) / (2000 - -1000) = 1000/3000 = 33 (% done)
    percentReverse = 100 - 33 = 66 (% left)
    

    Happy coding.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't

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.