0

我正在尝试根据手指从运动中的进度条执行的计算来移动第二个进度条,但出现强制关闭错误。

/* * Seekbar Mensualite */

seekbar_mensualite.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
{
   public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

       if (progress<20){
           progress=20;
       }

       else {

           progress=progress+10;
       }

       value_mensualite = progress;
       double duree = Math.ceil(progress_montant /progress);

       Log.i("Duree value_mensualite",Double.toString(duree));

          //text_dureee.setText(Double.toString(duree));

          Integer xxxi =  (int)(duree+ 0.5);
          seekbar_duree.setProgress(xxxi);


          DemandePret.mensualite = Util.decimalFormat(progress);

          DetailsPretPerso.mensualite = Util.decimalFormat(progress);
          DetailsPretPerso.seekbar_mensualite = progress;

      text_mensualitee.setText(Util.decimalFormat(progress));

   }

  public void onStartTrackingTouch(SeekBar seekBar) {}
  public void onStopTrackingTouch(SeekBar seekBar) {}

});


/*
 * Seekbar Duree
 */

seekbar_duree.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

   public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

       if (progress<12){
           progress=12;
       }

       else {

           progress=progress+1;
       }

       value_duree=progress;
       text_dureee.setText(Util.decimalFormat(progress));

       DemandePret.duree = Util.decimalFormat(progress);

       double duree = Math.ceil(progress_montant /progress);
       Integer xxxi =  (int)(duree+ 0.5);

       seekbar_mensualite.setProgress(xxxi);

       DetailsPretPerso.duree = Util.decimalFormat(progress);
       DetailsPretPerso.seekbar_duree = progress;

      // seekbar_mensualite.setProgress(duree);
      // text_mensualitee.setText(Util.decimalFormat(duree));
   }

  public void onStartTrackingTouch(SeekBar seekBar) {}

  public void onStopTrackingTouch(SeekBar seekBar) {}

});

这是我的错误日志:

05-23 16:45:11.871: E/AndroidRuntime(6508): FATAL EXCEPTION: main
05-23 16:45:11.871: E/AndroidRuntime(6508): java.lang.StackOverflowError
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.text.TextUtils.getChars(TextUtils.java:69)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.text.TextUtils.indexOf(TextUtils.java:102)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.text.StaticLayout.generate(StaticLayout.java:131)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.text.DynamicLayout.reflow(DynamicLayout.java:261)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.text.DynamicLayout.<init>(DynamicLayout.java:150)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.TextView.makeNewLayout(TextView.java:5080)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.TextView.checkForRelayout(TextView.java:5578)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.TextView.setText(TextView.java:2783)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.TextView.setText(TextView.java:2644)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.TextView.setText(TextView.java:2619)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at $2.onProgressChanged(class_name.java:141)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:507)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.refreshProgress(ProgressBar.java:516)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:565)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:546)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at $1.onProgressChanged(class_name.java:105)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:507)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.refreshProgress(ProgressBar.java:516)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:565)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:546)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at $2.onProgressChanged(class_name.java:149)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:507)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.refreshProgress(ProgressBar.java:516)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:565)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:546)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at $1.onProgressChanged(class_name.java:105)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:507)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.refreshProgress(ProgressBar.java:516)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:565)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:546)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at $2.onProgressChanged(class_name.java:149)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:507)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.refreshProgress(ProgressBar.java:516)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:565)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:546)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at $1.onProgressChanged(class_name.java:105)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:507)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.refreshProgress(ProgressBar.java:516)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:565)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:546)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at $2.onProgressChanged(class_name.java:149)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:507)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.refreshProgress(ProgressBar.java:516)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:565)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:546)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at $1.onProgressChanged(class_name.java:105)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.SeekBar.onProgressRefresh(SeekBar.java:89)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:507)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.refreshProgress(ProgressBar.java:516)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at android.widget.ProgressBar.setProgress(ProgressBar.java:565)
05-23 16:45:11.871: E/AndroidRuntime(6508):     at androi

错误出现在 ligne 141 上,即

           text_dureee.setText(Util.decimalFormat(progress));
4

1 回答 1

0

大概callseekbar_duree.setProgress(xxxi);里面onProgressChanged不是最好的选择。把它拿走,StackOverFlow应该消失

于 2013-05-23T12:54:26.747 回答