Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is the code that i used

Java
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();
				}
			}
		});
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900