user2902515
user2902515

Reputation: 193

Android progressbar not showing value

I created this topic few hours ago, which I solved my main issue with the help of user @J2K. Although, I thought the progressbar was doing well..but it's not.

My loop is this:

for(int i = list.size()-1; i >= 0; i--){

}

And he said to change the way I was output the value:

Change publishProgress((i * 100) / list.size()) to: publishProgress((list.size() - i * 100) / list.size())

The problem is that the value of progressbar doesn't change. It stays always in 0. So I tried to check the values:

Log.e("Value:", String.valueOf((list.size() - i * 100) / list.size()));

And I'm always receiving: Value: -99, and in the end of the loop:

11-07 10:25:43.196: E/Error H:(3187): java.lang.ArithmeticException: divide by zero

Edit: Solved.

Looking at my code of the other topic, the problem is that I was deleting from list the index..so I'll never get the total size of the list.

// Where total_list = amount of items in list
int total__ = total_list - i;
publishProgress((total__ * 100) / total_list);

Upvotes: 0

Views: 89

Answers (1)

kalyan pvs
kalyan pvs

Reputation: 14590

Your list is empty..thats why list.size() retuns zero..you are performing divide operation with zero.so it is giving you java.lang.ArithmeticException: divide by zero exception try check whether the list is empty or not..

Upvotes: 1

Related Questions