Programmatically change array stored in resources

374
January 28, 2017, at 12:01 PM

I have a toolbar. And spinner that set on it. Now this spinner is strongly integrated in my code. So I prefer not change the structure mentioned down. Now the problem is that I have to store array in the resources. This is the problem because I want to programatically add/(delete) items that stored there. So the question is: If it is possible to prepare this array in activity?(and store ready array into resources) Or if is possible to add/delete specific item to array that locate into resources?

toolbar = (Toolbar) findViewById(R.id.toolbar);
SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(getApplicationContext(), R.array.category, R.layout.spinner_dropdown_item);
            Spinner navigationSpinner = new Spinner(getSupportActionBar().getThemedContext());
            navigationSpinner.setAdapter(spinnerAdapter);
            toolbar.addView(navigationSpinner, 0);

This is how array looks like.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="category">
        <item>All lists</item>
        <item>Default</item>
        <item>Finished</item>
        <item>New List</item>
    </string-array>
</resources>

I found part of answer. But this allows only getting data from there, and not to store it after the treatment. How to add items to a stringArray in an arrayList programmatically?

READ ALSO
list.extend() cause the list to be char by char

list.extend() cause the list to be char by char

This is my code and the first logMessage() shows:

377
How to match the elements of dictionaries for the given Python List of Dictionaries?

How to match the elements of dictionaries for the given Python List of Dictionaries?

I have the following list of dictionariesI wanted to get the out put based on the start and close time

327
pyVisa too slow with RS232

pyVisa too slow with RS232

Simple program:

630
Function that works for multiple turtles

Function that works for multiple turtles

I know this is a very dumb question, but I haven't found any answersI've written a function with quite a long definition

326