Note that there are some explanatory texts on larger screens.

plurals
  1. POprogress bar only displays and does not update new to android
    primarykey
    data
    text
    <p>I am trying to produce a progress bar to tell me the percentage of the file that I have downloaded so far. The progress bar is displaying, but it does not ever update, it stays static.</p> <pre><code>while((line = reader.readLine()) != null) { values.add(line); } dialog = new ProgressDialog(ourContext); dialog.setCancelable(true); dialog.setMessage("File downloading..."); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgress(0); dialog.setMax(values.size()); dialog.show(); progressBarStatus = 0; fileSize = 0; new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub while(progressBarStatus &lt; values.size()){ for(int i = 0; i &lt; values.size();i++){ String[] data = values.get(i).split(","); //Log.d("Test drive " ,data[1] ); String[] dateSplit = data[1].split("[-]"); String month = dateSplit[1]; String day = dateSplit[0]; String year = dateSplit[2]; Calendar cal = Calendar.getInstance(); try { cal.setTime(new SimpleDateFormat("MMM").parse(month)); } catch (ParseException e) { // TODO Auto-generated catch block String error = e.toString(); Dialog d = new Dialog(ourContext); d.setTitle("Error"); TextView tv = new TextView(ourContext); tv.setText(error); d.setContentView(tv); d.show(); } int monthInt = cal.get(Calendar.MONTH) + 1; int yearInt = Integer.parseInt(year); int dayInt = Integer.parseInt(day); try { cashPotEntry(dayInt, monthInt, yearInt, data[3], data[2], data[4]); progressBarStatus++; Log.d("progress bar" ,progressBarStatus + " " ); Thread.sleep(1000); } catch (Exception e) { // TODO Auto-generated catch block String error = e.toString(); Dialog d = new Dialog(ourContext); d.setTitle("Error"); TextView tv = new TextView(ourContext); tv.setText(error); d.setContentView(tv); d.show(); } } progressBarHandler.post(new Runnable() { @Override public void run() { // TODO Auto-generated method stub dialog.setProgress(progressBarStatus); } }); } if(progressBarStatus &gt;= values.size()){ try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block String error = e.toString(); Dialog d = new Dialog(ourContext); d.setTitle("Error"); TextView tv = new TextView(ourContext); tv.setText(error); d.setContentView(tv); d.show(); } dialog.dismiss(); } } }).start(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload