How I set the color of ProgressBar from SQLite Int value? this code does not work for me.
myProgressB.setProgressColor(cb.color);
How I set the color of ProgressBar from SQLite Int value? this code does not work for me.
myProgressB.setProgressColor(cb.color);
You have to change it on update from another thread. I typically do this via an AsyncTask thread where I would override the onProgressUpdate as you download a file or do some other work
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
protected Long doInBackground(URL... urls) {
int count = urls.length;
long totalSize = 0;
for (int i = 0; i < count; i++) {
totalSize += Downloader.downloadFile(urls[i]);
publishProgress((int) ((i / (float) count) * 100));
// Escape early if cancel() is called
if (isCancelled()) break;
}
return totalSize;
}
protected void onProgressUpdate(Integer... progress) {
setProgressPercent(progress[0]);
// your work here
myProgressB.setProgressColor(cb.color);
}
protected void onPostExecute(Long result) {
showDialog("Downloaded " + result + " bytes");
}
}