2017-06-16 67 views
0

我正在從服務器加載數據到hashmap數組並顯示數據到listView中。 由於數據與圖像大,我想應用篩選器或分頁列表視圖加載只有10-15項目,當我點擊加載更多或向下滾動然後下一個數據出現在像Facebook的ListView的底部。 我正在使用Glide API來加載圖像並使用custome Adapter將數據設置到listView中。Android ListViewe從服務器加載大量數據的過濾

final String propertyID = contactList.get(position).get("property_id").toString(); 
    final String propertyTitle = contactList.get(position).get("property_title").toString(); 
    final String price = contactList.get(position).get("price").toString(); 
    String country = contactList.get(position).get("country").toString(); 
    String city = contactList.get(position).get("city").toString(); 
    String location = contactList.get(position).get("location").toString(); 
    final String landArea = contactList.get(position).get("landArea").toString(); 
    final String contact = contactList.get(position).get("phone").toString(); 
    String propertyType = contactList.get(position).get("property_type").toString(); 
    String propertystatus = contactList.get(position).get("status").toString(); 
    String description = contactList.get(position).get("property_description").toString(); 
    String rooms = contactList.get(position).get("rooms").toString(); 
    String bathrooms = contactList.get(position).get("bathrooms").toString(); 
    String floors = contactList.get(position).get("floors").toString(); 
    String status_property = contactList.get(position).get("status_property").toString(); 
    String dealer_email = contactList.get(position).get("dealer_email").toString(); 



    tv_property_id.setText(propertyID); 
    tv_propertyTitle.setText(propertyTitle); 
    tv_price.setText(price); 
    tv_country.setText(country); 
    tv_propertyCity.setText(city); 
    tv_propertyPhone.setText(contact); 
    tv_propertyPropertyLandArea.setText(landArea); 
    tv_protperty_type.setText(propertyType); 
    tv_protperty_status.setText(propertystatus); 
    tv_protperty_description.setText(description); 
    tv_propertyLocation.setText(location); 

    tv_propertyEmail.setText(dealer_email); 

    tv_property_rooms.setText(rooms); 
    tv_property_bathrooms.setText(bathrooms); 
    tv_property_floors.setText(floors); 
    tv_property_status_prpoperty.setText(status_property); 

    //imageLoader.DisplayImage(contactList.get(position).get("imageurl"), image); 

    Glide.with(activity) 
      .load(contactList.get(position).get("imageurl")) 
      .placeholder(R.drawable.default_image) 
      //.error(R.drawable.) 
      .override(200, 200) 
      .centerCrop() 
      .into(image); 

和適配器代碼是 HashMap中接觸=新的HashMap <>();

    contact.put("property_id", property_id); 
        contact.put("imageurl", imageURL); 
        contact.put("property_title", property_title); 
        contact.put("price", price); 
        contact.put("landArea", landArea); 
        contact.put("country", country); 
        contact.put("city", city); 
        contact.put("phone", phone); 
        contact.put("property_type", propertyType); 
        contact.put("status", propertystatus); 
        contact.put("property_description", description); 
        contact.put("location", propertyLocation); 

        contact.put("dealer_email", dealer_email); 

        contact.put("rooms", rooms); 
        contact.put("bathrooms", bathrooms); 
        contact.put("floors", floors); 
        contact.put("status_property", status_property); 

        contactList.add(contact); 

        Log.e("TAG", "Image URL: " + imageURL); 


       } 
      } catch (final JSONException e) { 
       Log.e(TAG, "Json parsing error: " + e.getMessage()); 
       runOnUiThread(new Runnable() { 
        @Override 
        public void run() { 
         Toast.makeText(getApplicationContext(), 
           "Json parsing error: " + e.getMessage(), 
           Toast.LENGTH_LONG).show(); 
        } 
       }); 

      } 

     } else { 
      Log.e(TAG, "Couldn't get json from server."); 
      runOnUiThread(new Runnable() { 
       @Override 
       public void run() { 
        Toast.makeText(getApplicationContext(), 
          "Please Check your Internet Connection!", 
          Toast.LENGTH_LONG).show(); 
       } 
      }); 
     } 

     adapter=new DataAdapter(ShowProperties.this, contactList); 
     list.setAdapter(adapter); 
     progressBar.setVisibility(View.GONE); 
    } 

我如何申請過濾,它只加載10,滾動後它加載更多十個等等。

回答

相關問題