I want to separate this string for a spinner.
Here I receive my JSON I go through it to only get what I want.
JSONObject jsonObject= new JSONObject(responseStrBuilder.toString());
JSONArray jsonArray = jsonObject.getJSONArray("payment_methods");
ArrayList<String> Lista = new ArrayList<>();
for(int i=0;i<jsonArray.length();i++){
try {
JSONObject json = jsonArray.getJSONObject(i);
//Aquí se obtiene el dato y es guardado en una lista
Lista.add(json.get("title").toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
ctOnGo.setMetodosPagos(Lista.toString());
ctOnGo.setMethodsPayments (List.toString ()); This is to save what I got it from the JSON
The spinner is here
//Spinner
SpinnerMethod = (Spinner) findViewById(R.id.spinner_methodopago);
String[] method = {ctPagar.getMetodosPagos()};
ctPagar.getMetodosPagos().split("\|");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, method);
SpinnerMethod.setAdapter(adapter);
Now I want this to save {ctPay.getMyPayments ()}; Looks like this:
Check / Money order
PayPal
Payment on delivery
Standard payment
But I get it in a chain: Check / Money order, PayPal, Payment on delivery, Standard payment