我正在尝试使用搜索栏创建贷款模拟器应用程序,当您更改搜索栏时,例如每月的还款额,贷款金额和也会改变的每月还款次数,我尝试了在贷款金额和每月付款,但没有给我我想要的结果
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_simulation,container, false);
final double t = 0.045;
final SeekBar seek_bar =(SeekBar) view.findViewById(R.id.seekBar);
final TextView text_view =(TextView) view.findViewById(R.id.textView);
final SeekBar seek_bar2 =(SeekBar) view.findViewById(R.id.seekBar2 );
final TextView text_view12 =(TextView) view.findViewById(R.id.textView12);
final SeekBar seek_bar3 =(SeekBar) view.findViewById(R.id.seekBar3);
final TextView text_view8 =(TextView) view.findViewById(R.id.textView8);
//amount of the loan
//seek_bar1
seek_bar.setMax(200000);
seek_bar.setMin(500);
text_view.setText("Covered: " + seek_bar.getProgress()+ "/"+seek_bar.getMax());
seek_bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
progress_value = progress;
text_view.setText("Covered: " + progress+ "/"+seek_bar.getMax());
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
text_view.setText("Covered: " + progress_value + "/"+seek_bar.getMax());
}
});
//number of monthly payments
//seek_bar2
seek_bar2.setMin(6);
seek_bar2.setMax(84);
text_view12.setText("Covered: " + seek_bar2.getProgress()+ "/"+seek_bar2.getMax());
seek_bar2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
progress_value1 = progress;
text_view12.setText("Covered: " + progress+ "/"+seek_bar2.getMax());
int b = (int)((progress_value*0.045/12)/1-pow(1+0.045/12,-progress_value2));
seek_bar3.setProgress(b);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
text_view12.setText("Covered: " + progress_value1 + "/"+seek_bar2.getMax());
}
});
//payment per month
//seek_bar3
seek_bar3.setMax(34007);
seek_bar3.setMin(200);
text_view8.setText("Covered: " + seek_bar3.getProgress()+ "/"+seek_bar3.getMax());
seek_bar3.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
progress_value2 = progress;
int a = (int)(((progress_value2*(1-pow(1+0.045/12,-progress_value1)))*12)/0.045);
seek_bar.setProgress(a);
double b = Math.log((-progress_value2)/(0.045/12)*progress_value - progress_value2)/Math.log(1+0.045/12);
int c = (int)b;
seek_bar2.setProgress(c);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
text_view8.setText("Covered: " + progress_value2 + "/"+seek_bar3.getMax());
}
});
return view;
}