1

I don't want to hardcode a double, so I wanted to put it in the values folder, either in a new XML or in the strings.xml

I know it exists:

<string name="a_string">my string</string>
<bool name="is_a_bool">true </bool>
<string-array name="string_array">
        <item>ítem 1</item>
        <item>ítem 2</item>
</string-array>

etcetera.

but how can I do to add a double?, like this:

<double name="a_double">-20.50</double>

cause I want to use it here:

<EditText
            android:layout_width="170dp"
            android:layout_height="wrap_content"
            android:inputType="number|numberDecimal|numberSigned"
            android:ems="10"
            android:id="@+id/txtLatitude"
            android:text="@.../a_double" />
RedDeath
  • 283
  • 4
  • 17

2 Answers2

0

You have to put your double in a string:

<string name="a_double">-20.50</string>

And you it in layout as this:

<EditText
            android:layout_width="170dp"
            android:layout_height="wrap_content"
            android:inputType="number|numberDecimal|numberSigned"
            android:ems="10"
            android:id="@+id/txtLatitude"
            android:text="@string/a_double" />

Please visit Android developer website, there's no double resources:

http://developer.android.com/guide/topics/resources/available-resources.html http://developer.android.com/guide/topics/resources/more-resources.html

LaurentY
  • 7,495
  • 3
  • 37
  • 55
  • yes, that's what I finally did. But was wondering if there was any XML value for doubles, cause it does exist for integer :) – RedDeath Feb 20 '15 at 10:56
0

No you have to set your any data type value in Sting formate :

<string name="price">2.6555</string>

Whenever you use the value just Parse it in the original data type.

Akshay Paliwal
  • 3,718
  • 2
  • 39
  • 43