Mysql没有';在Android应用程序中无法获得完美的结果

Mysql没有';在Android应用程序中无法获得完美的结果,android,mysql,Android,Mysql,你能看到的第一张大学名单。 当我点击第一所大学时,我得到了完美的结果 单击“上一所大学”时,我没有得到结果..请提供帮助 这里 1) ListCollege.java//First Activity这是给我学院列表//第一张图片 collegelist=(ListView)findViewById(R.id.collegeList); InputStream is = null; String result = ""; //the year data to s

你能看到的第一张大学名单。 当我点击第一所大学时,我得到了完美的结果 单击“上一所大学”时,我没有得到结果..请提供帮助

这里 1) ListCollege.java//First Activity这是给我学院列表//第一张图片

    collegelist=(ListView)findViewById(R.id.collegeList);
    InputStream is = null;

    String result = "";
     //the year data to send
     ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
     nameValuePairs.add(new BasicNameValuePair("searchcollege",search_college));
     nameValuePairs.add(new BasicNameValuePair("searchcity",search_city));

     //http post
     try{
             HttpClient httpclient = new DefaultHttpClient();
             HttpPost httppost = new HttpPost("http://www.career4u.org/android/android_connection.php");
             httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
             HttpResponse response = httpclient.execute(httppost);
             HttpEntity entity = response.getEntity();
             is = entity.getContent();

     }catch(Exception e){
             Log.e("log_tag", "Error in http connection "+e.toString());
     }

     //convert response to string
     try{
             BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
             StringBuilder sb = new StringBuilder();
             String line = null;
             while ((line = reader.readLine()) != null) {
                     sb.append(line + "\n");
             }
             is.close();
             result=sb.toString();
             String result1[]=result.split("\\}\\,\\{");
             for(int i=0;i<=result1.length;i++)
             {
                     result1[i]= result1[i].replace("[{", "").replace("institue_name", "").replace("\"", "").replace("}]", "").replace(":", "");
                     collegelist.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , result1));  
                     collegelist.setOnItemClickListener(new OnItemClickListener() {
                          public void onItemClick(AdapterView<?> parent, View view,
                              int position, long id) {
                            Intent intent = new Intent(ListCollege.this,viewCollege.class);
                            intent.putExtra("search_college", ((TextView) view).getText());
                            startActivity(intent);
                         }
                        });
             } 

     }catch(Exception e){
             Log.e("log_tag", "Error converting result "+e.toString());
     }
     //parse json data
}
collegelist=(ListView)findViewById(R.id.collegelist);
InputStream=null;
字符串结果=”;
//要发送的年度数据
ArrayList nameValuePairs=新的ArrayList();
添加(新的BasicNameValuePair(“searchcollege”,search_college));
添加(新的BasicNameValuePair(“搜索城市”,搜索城市));
//http post
试一试{
HttpClient HttpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(“http://www.career4u.org/android/android_connection.php");
setEntity(新的UrlEncodedFormEntity(nameValuePairs));
HttpResponse response=httpclient.execute(httppost);
HttpEntity=response.getEntity();
is=entity.getContent();
}捕获(例外e){
e(“Log_标记”,“http连接错误”+e.toString());
}
//将响应转换为字符串
试一试{
BufferedReader reader=新的BufferedReader(新的InputStreamReader(is,“iso-8859-1”),8;
StringBuilder sb=新的StringBuilder();
字符串行=null;
而((line=reader.readLine())!=null){
sb.追加(第+行“\n”);
}
is.close();
结果=sb.toString();
字符串result1[]=result.split(“\\}\,\\{”);

对于(int i=0;i,请查看您代码的这一部分:

     for(int i=0;i<=result1.length;i++)
     {
             result1[i]= result1[i].replace("[{", "").replace("institue_name", "").replace("\"", "").replace("}]", "").replace(":", "");
             collegelist.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , result1));  
             collegelist.setOnItemClickListener(new OnItemClickListener() {
                  public void onItemClick(AdapterView<?> parent, View view,
                      int position, long id) {
                    Intent intent = new Intent(ListCollege.this,viewCollege.class);
                    intent.putExtra("search_college", ((TextView) view).getText());
                    startActivity(intent);
                 }
                });
     } 

for(int i=0;i使用而不是使用
BufferedReader
/
StringBuilder
--更少的代码,它遵守服务器发送的字符编码。另外,不要使用自己的JSON解析器!使用内置库或其他库,如Gson、Jackson等,并假设调用
findViewById()
,您正在UI线程中执行网络IO(
onCreate()
等)--不要这样做!一旦应用程序以真实的网络速度和响应时间在真实设备上运行,Android将强制关闭应用程序。请改用一个命令—在
doInBackground()
中执行HTTP,然后从
onPostExecute()
更新您的UI。
     for(int i=0;i<=result1.length;i++)
     {
             result1[i]= result1[i].replace("[{", "").replace("institue_name", "").replace("\"", "").replace("}]", "").replace(":", "");
             collegelist.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , result1));  
             collegelist.setOnItemClickListener(new OnItemClickListener() {
                  public void onItemClick(AdapterView<?> parent, View view,
                      int position, long id) {
                    Intent intent = new Intent(ListCollege.this,viewCollege.class);
                    intent.putExtra("search_college", ((TextView) view).getText());
                    startActivity(intent);
                 }
                });
     } 
collegelist.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , result1));
collegelist.setOnItemClickListener(new OnItemClickListener()...