我正在使用以下代码在我的一项活动中填充 Spinner ...
for( double i = 0; i < 10 ; i+=0.1 ) {
rVoltsList.add( Double.toString( i ) );
}
Spinner rVoltsSpinner = (Spinner) findViewById( R.id.recloseVoltsSpinner );
ArrayAdapter<String> rVoltsAdapter = new ArrayAdapter<String>( this, android.R.layout.simple_spinner_item, rVoltsList );
rVoltsSpinner.setAdapter( rVoltsAdapter );
我假设这会给我一个如下列表:0.0、0.1、0.2、0.3、0.4 等等。但是,这是我运行程序时列表的样子:
0.0
0.1
0.2
0.30000000000000000000000004
0.4
0.5
0.6
0.7
0.79999999999999999999
0.89999999999999999999
0.99999999999999999999
1.09999999999999999999
1.2
1.3
and this goes on until 9.99999999999999999998
有任何想法吗?