Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Seekbar因字符串格式而崩溃_Java_Android_Seekbar_Changelistener - Fatal编程技术网

Java Seekbar因字符串格式而崩溃

Java Seekbar因字符串格式而崩溃,java,android,seekbar,changelistener,Java,Android,Seekbar,Changelistener,当我在format方法中输入%0.02f作为参数时,我的tip calculator应用程序上的SeekBar崩溃 tipAmountEditText.setText(String.format("%0.02f", tipAmount)); 我解决了这个问题,删除了整数部分,因此变成了%.02f。关于这个问题,我能说的唯一一个特性是它是使用ChangeListener弹出的。我不明白为什么这会是一个问题,我希望有人能启发我。如果您需要了解更大的情况,我的代码全部都在我的github上: 这里是

当我在format方法中输入%0.02f作为参数时,我的tip calculator应用程序上的SeekBar崩溃

tipAmountEditText.setText(String.format("%0.02f", tipAmount));
我解决了这个问题,删除了整数部分,因此变成了
%.02f
。关于这个问题,我能说的唯一一个特性是它是使用ChangeListener弹出的。我不明白为什么这会是一个问题,我希望有人能启发我。如果您需要了解更大的情况,我的代码全部都在我的github上:

这里是
String.format(“%0.02f”,tipAmount)
您将获得

java.util.MissingFormatWidthException

//This Unchecked exception thrown when the format width is required.

原因:

因此,请使用下面的方法


我可以知道
#
的目的吗?另外,零是如何导致崩溃的?这是参数格式问题吗?
java.util.MissingFormatWidthException

//This Unchecked exception thrown when the format width is required.
%0.02f interprets as a floating point at least 0 wide.

Thats why it gives MissingFormatWidthException // as its assuming width to 0
String.format("%.02f", tipAmount)