如何使用json webservice在android中填充spinner

如何使用json webservice在android中填充spinner,android,json,android-spinner,Android,Json,Android Spinner,我用了这个密码 HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://www.wisknowtech.com/hotel_jobs/country_list.php"); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseB

我用了这个密码

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.wisknowtech.com/hotel_jobs/country_list.php");         
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httppost,responseHandler);                     
JSONObject json = new JSONObject(responseBody);

JSONArray jArray = json.getJSONArray("data");
//JSONArray  jsonArray = new JSONArray(responseBody);

final String[] array_spinner = new String[jArray.length()];                         

final Spinner countryspiner = (Spinner) findViewById(R.id.rescountry);                             
ArrayAdapter<String> classNameAdapter = new ArrayAdapter<String>(this,                            android.R.layout.simple_spinner_item,array_spinner);
                 classNameAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
for (int i=0; i<jArray.length(); i++)
{
     String styleValue = jArray.getJSONArray(i).getString(0); 
     array_spinner[i] = styleValue;
}
countryspinner.setAdapter(classNameAdapter);
}
catch (JSONException e) {
    e.printStackTrace();
} catch (ClientProtocolException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}  
HttpClient-HttpClient=newdefaulthttpclient();
HttpPost HttpPost=新的HttpPost(“http://www.wisknowtech.com/hotel_jobs/country_list.php");         
ResponseHandler ResponseHandler=新BasicResponseHandler();
字符串responseBody=httpclient.execute(httppost,responseHandler);
JSONObject json=新的JSONObject(ResponseBy);
JSONArray jArray=json.getJSONArray(“数据”);
//JSONArray JSONArray=新的JSONArray(响应库);
最终字符串[]数组_微调器=新字符串[jArray.length()];
最终微调器countryspiner=(微调器)findViewById(R.id.rescountry);
ArrayAdapter classNameAdapter=新的ArrayAdapter(这是android.R.layout.simple\u微调器\u项,数组微调器);
classNameAdapter.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
对于(int i=0;i