From 6aadbeecd63ec5118275cc0c89af2d0d0a87be36 Mon Sep 17 00:00:00 2001 From: Ayrton <46231350+ayrtton@users.noreply.github.com> Date: Fri, 9 Jul 2021 11:43:49 -0300 Subject: [PATCH] Save Button Fix Fix for java.lang.NumberFormatException. --- app/src/main/java/com/example/inventory/AddItemFragment.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/inventory/AddItemFragment.kt b/app/src/main/java/com/example/inventory/AddItemFragment.kt index 6fd3e38f..d2dae7b5 100644 --- a/app/src/main/java/com/example/inventory/AddItemFragment.kt +++ b/app/src/main/java/com/example/inventory/AddItemFragment.kt @@ -28,6 +28,7 @@ import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import com.example.inventory.data.Item import com.example.inventory.databinding.FragmentAddItemBinding +import java.util.Locale /** * Fragment to add or update an item in the Inventory database. @@ -76,7 +77,7 @@ class AddItemFragment : Fragment() { * Binds views with the passed in [item] information. */ private fun bind(item: Item) { - val price = "%.2f".format(item.itemPrice) + val price = "%.2f".format(Locale.US, item.itemPrice) binding.apply { itemName.setText(item.itemName, TextView.BufferType.SPANNABLE) itemPrice.setText(price, TextView.BufferType.SPANNABLE)