CircularProgressBar正在我的应用程序停止

时间:2017-03-01 21:47:22

标签: java android progress-bar android-progressbar

我可以在两个日期之间做android差异,但我添加了循环渐进,我使用mikhaellopez.circularprogressbar。但是我不能它

 package com.yavuzoktay.derszamani;

         import android.support.v7.app.AppCompatActivity;
               import android.os.Bundle;
  import android.widget.Toast;

 import com.mikhaellopez.circularprogressbar.CircularProgressBar;

import org.joda.time.*;
         import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;

       public class SinavaKalanGun extends AppCompatActivity {
    private TextView txtYears,txtMonths,txtDays,txtHours,txtMinutes,txtSinavTarihi;

CircularProgressBar pbYgsYear;
CircularProgressBar pbYgsAy;
CircularProgressBar pbYgsGun;
CircularProgressBar pbYgsSaat;



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sinava_kalan_gun);

    txtYears =  (TextView)  findViewById(R.id.tv_year);
    txtMonths = (TextView) findViewById(R.id.tv_month);
    txtDays = (TextView) findViewById(R.id.tv_day);
    txtHours=  (TextView)   findViewById(R.id.tv_hour);
    txtMinutes=  (TextView)   findViewById(R.id.tv_minute);
    txtSinavTarihi= (TextView) findViewById(R.id.tv_sinavTarihi);
        /*
    DateTimeFormatter format = DateTimeFormat.forPattern("MM/dd/yyyy HH:mm:ss");
    String dob = "05/14/2018 19:29:58 ";


    LocalTime localTime = new LocalTime();
    LocalDate localDate = new LocalDate();
    DateTime dateTime = new DateTime();
    LocalDateTime localDateTime = new LocalDateTime();
    DateTimeZone dateTimeZone = DateTimeZone.getDefault();


    txtDays.setText(Years.yearsBetween(dateTime,DateTime.parse(dob)).getYears()+" Yıl Kaldı");
    txtDays2.setText(Months.monthsBetween(dateTime,DateTime.parse(dob)).getMonths()+"Ay Kaldı");
    txtDays3.setText(Days.daysBetween(dateTime,DateTime.parse(dob)).getDays()+"Gün Kaldı");

   // txtDays4.setText(Hours.hoursBetween(dateTime,DateTime.parse(dob)).getHours() %24 +"saat");

    */

    //Kodlar ıse yarıyor ancak veriyi Türkiyeden cekmiyor
    final String dateStop = "04/18/2017 09:00:00";
    final DateTimeFormatter format = DateTimeFormat.forPattern("MM/dd/yyyy HH:mm:ss");
    final DateTime dt1 = format.parseDateTime(dateStop);
    DateTime dateTime = new DateTime(); //su andaki zamanı göstermek icin
    DateTimeZone dateTimeZone = DateTimeZone.getDefault(); //hangi ulkenin saatini kullandıgını görmek ıcın
    LocalTime localTime = new LocalTime();
    LocalDate localDate = new LocalDate();
    LocalDateTime localDateTime = new LocalDateTime();

    /*txtDays.setText(Years.yearsBetween(dateTime,DateTime.parse(dob)).getYears()+" Yıl Kaldı");
    txtDays2.setText(Months.monthsBetween(dateTime,DateTime.parse(dob)).getMonths()+"Ay Kaldı");
       */ // aynı kodların diger yolla yapılıs seklidir.

    final Period period = new Period(dateTime, dt1);

    txtYears.setText(period.getYears()+"Yıl");
    txtMonths.setText(period.getMonths()+"Ay ");
    txtDays.setText(period.getDays() + "Gün ");
    txtHours.setText(period.getHours() + "Saat ");
    txtMinutes.setText(period.getMinutes()+"Dakika Kaldı");
    txtSinavTarihi.setText("18 Şubat 2017");
    //txtDays3.setText(period.getMinutes() + " minutes, ");

    this.pbYgsYear.setProgressWithAnimation(progressSetle(Integer.valueOf(this.txtHours.getText().toString())));


    Toast.makeText(SinavaKalanGun.this,"Tahmini olarak girilmiştir ÖSYM adresinden güncelini takip edebilirsiniz"
            ,Toast.LENGTH_SHORT).show();



}

private float progressSetle(int paramInt) {
    return  (360 - paramInt)*100/360.0F;
}



 }

我认为我的错误是这个图片代码因为我认为我写错了

enter image description here

您的建议对我很重要

谢谢!

1 个答案:

答案 0 :(得分:0)

你打电话

this.pbYgsYear.setProgressWithAnimation(progressSetle(Integer.valueOf(this.txtHours.getText().toString())));

首先没有初始化pbYgsYear

你可以写

来做到这一点

pbYgsYear = (CircularProgressBar) findViewById(R.id.pbYgsYear);(或XML中的任何ID)

TextView中的onCreate()一样。