samedi 23 juillet 2016

How to change a value from an XML file using Java

I have an integers.xml located at res/values. What I want to achieve is to change a value (an int) to some other int, by using Java. This is my code and as you can see I am using the Random class to assign it to the xml Degree value. But it doesn't work...

btnStart.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Random objRandom = new Random();
            int intRandomNumber  = objRandom.nextInt(1440 - 1080 + 1) + 1080;
            int intXMLDegree = getResources().getInteger(R.integer.Degree);
            intXMLDegree = intRandomNumber;

            iv.startAnimation(rotation);


        }
    });

Aucun commentaire:

Enregistrer un commentaire