如何过滤pojo类并从中创建新的pojo类

时间:2017-12-12 06:29:50

标签: java android pojo

我有一个POJO课程。 ContactPOJO.class

 @PrimaryKey(autoGenerate = true)
    private  int id;
    private  String contact_id;
    private  String contact_name;
    private  String contact_number;
    private  boolean is_selected;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getContact_id() {
        return contact_id;
    }

    public void setContact_id(String contact_id) {
        this.contact_id = contact_id;
    }


    public boolean isIs_selected() {
        return is_selected;
    }

    public void setIs_selected(boolean is_selected) {
        this.is_selected = is_selected;
    }

    public String getContact_name() {
        return contact_name;
    }

    public void setContact_name(String contact_name) {
        this.contact_name = contact_name;
    }

    public String getContact_number() {
        return contact_number;
    }

    public void setContact_number(String contact_number) {
        this.contact_number = contact_number;
    }

现在我必须创建新的POJO类,但仅限于在ContactPOJO中is_selected布尔值为true的那个。我不知道该怎么做。任何帮助都会很感激。谢谢你提前

编辑:我有 List<ContactPOJO> list_contact 。其中包含手机的所有联系人。现在他们中的一些将被选中,其中一些将不会被选中。它的选择与否将存储在is_selected变量中。现在我必须制作新的列表.lets说 List<newContactPOJO> 。但它只包含那个旧值的is_selected真值。

1 个答案:

答案 0 :(得分:0)

@Override
public void onLocationChanged(Location location) {
    mLastLocation = location;
    // use latitude and longitude given by 
    // location.getLatitude(), location.getLongitude()
    // for updated location marker
    Log.d("aaaaaaaa===>", "" + location.getLatitude() + "\n" + location.getLongitude());
   // displayLocation();

    // to remove old markers
    googleMa.clear();
    final LatLng loc = new LatLng(location.getLongitude(), location.getLongitude());

    Marker ham = googleMa.addMarker(new MarkerOptions().position(loc).title("This is Me").icon(BitmapDescriptorFactory.fromResource(R.drawable.greenpointer)));
    googleMa.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, 15));
}

==&GT;现在您有一个包含所有选定对象的新列表

相关问题