Java 自定义POJO的筛选列表视图';在他们的田地旁
我有一个POJO:Java 自定义POJO的筛选列表视图';在他们的田地旁,java,android,listview,filtering,Java,Android,Listview,Filtering,我有一个POJO: public class RoomData implements Parcelable { private String objectId, name, building, floor, imageUrl; private boolean hasPc, hasProjector, hasTelepresence, hasWhiteboard; private boolean dataReady = false; private ArrayLis
public class RoomData implements Parcelable {
private String objectId, name, building, floor, imageUrl;
private boolean hasPc, hasProjector, hasTelepresence, hasWhiteboard;
private boolean dataReady = false;
private ArrayList<MeetingData> meetingData = new ArrayList<MeetingData>();
private int capacity;
private ArrayList<BeaconData> beacons = new ArrayList<BeaconData>();
private DateTime nextAvailableStart, nextAvailableEnd;
private boolean availableNow = false;
private ArrayList<Interval> meetingDuringIntervals = new ArrayList<Interval>();
}
在OP的要求下,我将我的评论作为回答,以备将来参考,并提供更多细节。以下是一些可能的解决方案:
getItem(int-pos)
中,您在列表中循环保存一个计数器,但只有当该项与过滤器匹配时,您才增加它:当计数器等于pos时,您返回该项。其他方法也类似只需在列表中循环筛选出你不需要的内容。或者,如果需要更改过滤器,可以保留一个新列表,该列表是整个列表的视图。然后在AdapterID中的整个列表上使用视图。很好。发布它,我将接受它作为解决方案。谢谢@Gil
public class BeaconAdapter extends BaseAdapter {
private Context context;
private ArrayList<BLEDeviceAdvertisement> beaconArrayList = new ArrayList<BLEDeviceAdvertisement>();
private static LayoutInflater inflater = null;
//BeaconAdapter for the custom ListView
public BeaconAdapter(Context context, ArrayList<BLEDeviceAdvertisement> beaconArrayList) {
this.beaconArrayList = beaconArrayList;
this.context = context;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return beaconArrayList.size();
}
@Override
public BLEDeviceAdvertisement getItem(int position) {
return beaconArrayList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
//Custom getview for the custom layout beacon_row_item.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View myCustomView = convertView;
if (myCustomView == null)
myCustomView = inflater.inflate(R.layout.beacon_row_item, null);
return myCustomView;
}
}