public void onSuccess(String response) { try{ JSONObject obj = new JSONObject(response); final JSONArray jsonArray = obj.getJSONArray("PopulateSuppliersListResult"); int length = jsonArray.length(); List<String> listContents = new ArrayList<String>(length); for (int i = 0; i < length; i++) { JSONObject user = jsonArray.getJSONObject(i); listContents.add(user.getString("ID")); } supname= (Spinner) findViewById(R.id.spinner1); supname.setAdapter(new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, listContents)); supname.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub try { iActivationStatusID=jsonArray.getJSONObject(position).getString("ID"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO Auto-generated method stub } }); }catch(JSONException e){ e.printStackTrace(); } } });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)