new String[num];
Ram = new String[num];
BCamera = new String[num];
Screesize = new String[num];
Battery = new String[num];
ImgUrl=new String[num];
return true;
}
//获取网络请求结果
private String connServerForResult(String strUrl)
{
// HttpGet对象
HttpGet httpRequest = new HttpGet(strUrl);
String strResult = "";
try
{
// HttpClient对象
HttpClient httpClient = new DefaultHttpClient();
// 获得HttpResponse对象
HttpResponse httpResponse = httpClient.execute(httpRequest);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
// 取得返回的数据
strResult = EntityUtils.toString(httpResponse.getEntity());
}
} catch (ClientProtocolException e)
{
System.out.println("protocol error:"+e.getMessage());
e.printStackTrace();
Log.d("check","protocol error:"+e.getMessage());
solveNoConnection();
} catch (IOException e)
{
System.out.println("IO error:"+e.getMessage());
e.printStackTrace();
Log.d("check","IO error:"+e.getMessage());
solveNoConnection();
}
return strResult;
}
//网络请求错误时执行
private Boolean solveNoConnection(){
Log.d("check","网络请求错误处理!");
searchState.setText("无网络或网络访问失败!");
return true;
}
// 普通Json数据解析
private void parseJson(String strResult)
{
try
{
JSONObject jsonObj = new JSONObject(strResult);
int count=Integer.parseInt(jsonObj.getString("num").toString());
Count=count;
inintInfo(count);
Log.d("check","parseJson:"+jsonObj.toString());
JSONArray PhoneId=jsonObj.getJSONArray("Id");
JSONArray brands=jsonObj.getJSONArray("Brands");
JSONArray price=jsonObj.getJSONArray("Price");
JSONArray name=jsonObj.getJSONArray("Name");
JSONArray nettype=jsonObj.getJSONArray("Nettype");
JSONArray cpu=jsonObj.getJSONArray("Cpu");
JSONArray ram=jsonObj.getJSONArray("Ram");
JSONArray bCamera=jsonObj.getJSONArray("BCamerab");
JSONArray screesize=jsonObj.getJSONArray("Screesize");
JSONArray battery=jsonObj.getJSONArray("Battery");
JSONArray imgUrl=jsonObj.getJSONArray("ImgUrl");
for(int i=0;i
Id[i]=PhoneId.getString(i).toString();
Brands[i]=brands.getString(i);
Price[i]=price.getString(i);
Name[i]=name.getString(i);
Nettype[i]=nettype.getString(i);
Cpu[i]=cpu.getString(i);
Ram[i]=ram.getString(i);
BCamera[i]=bCamera.getString(i);
Screesize[i]=screesize.getString(i);
Battery[i]=battery.getString(i);
ImgUrl[i]=HomeUrl+imgUrl.getString(i);
Log.d("check", "parseJson获取图片地址:"+ImgUrl[i]);
}
}catch (JSONException e)
{
System.out.println("Json p
上一篇:游戏门户网站APP毕业论文
下一篇:法律专业开题报告范文