I am playing around for the first time with android development. I am trying to make a simple currency converter app. The particular piece I am working on is populating a spinner box with all of the available currencies without having to code it all in manually. I have a json file that looks like:
{
"AED": "United Arab Emirates Dirham",
"AFN": "Afghan Afghani",
"ALL": "Albanian Lek",
"AMD": "Armenian Dram",
"ANG": "Netherlands Antillean Guilder",
"AOA": "Angolan Kwanza",
"ARS": "Argentine Peso",
"AUD": "Australian Dollar",
"AWG": "Aruban Florin",
...
}
I want to read that object one currency at a time so I can use it to populate the spinner. Something along the lines of:
/*PSEUDOCODE*/
spinner = (Spinner) findViewById(R.id.currencyTo);
List<String> list = new ArrayList<String>();
JSONParser jParser = new JSONParser();
JSONObject json = jParser.getJSONFromUrl(url);
while (rates != null) {
rates = json.getString(first item in json);
list.add(rates);
...
I know how to do it by calling each item individually, such as rates = json.getString("AED") and so on, but I don't want it so hardcoded like that. I want to parse each currency item individually, then place it in the spinner. Grab the next currency, place it in the spinner, and so on and so forth. Any help is greatly appreciated.