Following is my integers.xml
file,
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="LOCATION_ALARM_INTERVAL">60000</integer>
<integer name="MID_NIGHT_ALARM_INTERVAL">86400000</integer>
</resources>
if it was strings.xml
, i could have access variable like below,
getString( R.string.<variable_name> );
but how can I do same to get value from integeres.xml file ?
when I write getResources().getInteger(R.integer.
it is showing me 3 variable which I haven't declared.
So How can I access the variable which I declared in integers.xml
file ?
It should be done like this:
Resources res = getResources();
int i= res.getInteger(R.integer.int_value);
where int_value is the variable name given in your xml
You're looking at the android.R.integer
instead of your.namespace.R.integer
.
Eclipse probably imported the wrong one; it does that sometimes, it's rather annoying.
Go to your imports at the top of the file and remove:
import android.R;
Then you should be able to use the quick-fix to add the correct import.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With