2016-09-23 112 views
0

每當我試圖從JsonArray中移除一個對象時,它就會顯示沒有這樣的方法存在。我的目標API版本是8.我查找有關此問題的其他問題,但無法找到合適的解決方案。請幫我解決一下這個。圖像在滾動的自定義列表視圖中重複

class JSONAsync extends AsyncTask<String, Void, JSONArray> 
{ 


    @Override 
    protected void onPreExecute() 
    { 
     super.onPreExecute(); 
     progressDialog = Util.setProgressDialog(Activity.this, "Please Wait", 
       "loading....", false); 
     progressDialog.show(); 
    } 

    @Override 
    protected JSONArray doInBackground(String... urls) 
    { 

     try 
     {  
      HttpGet httppost = new HttpGet(url); 
      HttpClient httpclient = new DefaultHttpClient(); 
      HttpResponse response = httpclient.execute(httppost); 

      // StatusLine stat = response.getStatusLine(); 
      int status = response.getStatusLine().getStatusCode(); 

      if (status == 200) 
      { 
       HttpEntity entity = response.getEntity(); 
       String resString = EntityUtils.toString(entity); 

       JSONObject jso= new JSONObject(resString); 

       JSONArray jsono= jso.getJSONArray("jobmasterto"); 
       Log.e("jason array is this", ""+jsono); 
       for (int i = 0; i < jsono.length(); i++) { 
        if (jsono.getJSONObject(i).getString("jobName").equals(null) || jsono.getJSONObject(i).getString("jobName").equals("null") || jsono.getJSONObject(i).getString("jobName").equals("")) { 
         Log.e("Output : : ", jsono.getJSONObject(i).getString("jobName")); 
         jsono.remove(i); 
        } 



       }    
       if(jsono.length()>=0) 
       { 
        jobname = new String[(jsono.length())]; 
        jobid = new String[(jsono.length())]; 
        for(int i=0;i<jsono.length();i++) 
        { 
         JSONObject js = jsono.getJSONObject(i); 

          Log.e("Name : ", jsono.getJSONObject(i).getString("jobName")); 
          jobname[i] = jsono.getJSONObject(i).getString("jobName"); 
          Log.e("Id : ", jsono.getJSONObject(i).getString("jobId")); 
          jobid[i] = jsono.getJSONObject(i).getString("jobId"); 

        } 
        return jsono; 
       } 
       else 
       { 
        Toast.makeText(getApplicationContext(), "No Workers available : "+ logedinUserId , Toast.LENGTH_LONG).show(); 
        return null; 
       } 
      } 


     } catch (IOException e) 
     { 
      e.printStackTrace(); 
     } catch (JSONException e) 
     { 
      e.printStackTrace(); 
     } 
     return null;  
    } 

    protected void onPostExecute(JSONArray result) 
    { 
     progressDialog.dismiss(); 

    } 
} 
+0

發表您的自定義適配器類的'getView()'方法 –

回答

0
  1. 你真的想頭疼支持這麼老設備的比特數量?
  2. 然而,使用此:

    JSONObject jso= new JSONObject(resString); 
    
    JSONArray jsonArray = jso.getJSONArray("jobmasterto"); 
    
    Log.e("jason array is this", ""+jsonArray); 
    ArrayList<Integer> i_ar = new ArrayList<Integer>(); 
           for (int i = 0; i < jsonArray.length(); i++) { 
            if (jsonArray.getJSONObject(i).getString("jobName").equals(null) || jsonArray.getJSONObject(i).getString("jobName").equals("null") || jsonArray.getJSONObject(i).getString("jobName").equals("")) { 
             Log.e("Output : : ", jsonArray.getJSONObject(i).getString("jobName")); 
             i_ar.add(i); 
            } 
    
    
    
           }    
    
    JSONArray jsono = new JSONArray(); 
    
    int len = jsonArray.length(); 
    if (jsonArray != null) { 
        for (int i=0;i<len;i++) 
        { 
         //Excluding the item at position 
         if (i_ar.indexOf(i) == -1) 
         { 
          list.put(jsonArray.get(i)); 
         } 
        } 
    } 
    
    
    
           if(jsono.length()>=0) 
           { 
    //.... continue... 
    
相關問題