Fix EditText decimal format
This commit is contained in:
parent
3c6c6439f0
commit
ec8f63a396
1 changed files with 5 additions and 3 deletions
|
@ -37,6 +37,7 @@ import net.osmand.util.Algorithms;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
|
||||
|
@ -76,6 +77,7 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
|
|||
final TextView metric = mainView.findViewById(R.id.metric);
|
||||
metric.setText(app.getString(preference.getAssets().getMetricRes()));
|
||||
final RecyclerView recyclerView = mainView.findViewById(R.id.recycler_view);
|
||||
final DecimalFormat df = new DecimalFormat("#.####");
|
||||
text = mainView.findViewById(R.id.text_edit);
|
||||
try {
|
||||
currentValue = Float.parseFloat(preference.getValue());
|
||||
|
@ -83,8 +85,7 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
|
|||
currentValue = 0.0f;
|
||||
}
|
||||
selectedItem = preference.getEntryFromValue(preference.getValue());
|
||||
|
||||
String currentValueStr = currentValue == 0.0f ? "" : String.valueOf(currentValue + 0.01f);
|
||||
String currentValueStr = currentValue == 0.0f ? "" : String.valueOf(df.format(currentValue + 0.01f));
|
||||
text.setText(currentValueStr);
|
||||
text.clearFocus();
|
||||
text.setOnTouchListener(new View.OnTouchListener() {
|
||||
|
@ -130,7 +131,8 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
|
|||
public void onItemSelected(String item) {
|
||||
selectedItem = item;
|
||||
currentValue = preference.getValueFromEntries(selectedItem);
|
||||
String currentValueStr = currentValue == 0.0f ? "" : String.valueOf(currentValue + 0.01f);
|
||||
String currentValueStr = currentValue == 0.0f
|
||||
? "" : String.valueOf(df.format(currentValue + 0.01f));
|
||||
text.setText(currentValueStr);
|
||||
if (text.hasFocus()) {
|
||||
text.setSelection(text.getText().length());
|
||||
|
|
Loading…
Reference in a new issue