在我的点文件中
public class MyListAdapter extends BaseAdapter implements Filterable {
private List<Product> myList;
private List<Product> myListFull;
private LayoutInflater mInflater;
public MyListAdapter(List<Product> data, Context context) {
myList = data;
myList = new ArrayList(myList);
myListFull = new ArrayList(myList);
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return myList.size();
}
@Override
public Object getItem(int position) {
return myList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyListAdapter.ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.listitem, parent, false);
holder = new MyListAdapter.ViewHolder();
holder.title = convertView.findViewById(R.id.listitem_title);
holder.description = convertView.findViewById(R.id.listitem_subtitle);
convertView.setTag(holder);
} else {
holder = (MyListAdapter.ViewHolder) convertView.getTag();
}
Product mProduct = (Product)getItem(position);
holder.title.setText(mProduct.getProductName());
holder.description.setText(mProduct.getProductDescription());
return convertView;
}
/**
* View holder
*/
static class ViewHolder {
private TextView title;
private TextView description;
}
@Override
public Filter getFilter() {
return exampleFilter;
}
private Filter exampleFilter = new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
List<Product> filteredList = new ArrayList<>();
if (constraint == null || constraint.length() == 0) {
filteredList.addAll(myListFull);
} else {
String filterPattern = constraint.toString().toLowerCase().trim();
for (Product item : myListFull) {
if (item.getProductName().toLowerCase().contains(filterPattern)) {
filteredList.add(item);
}
}
}
FilterResults results = new FilterResults();
results.values = filteredList;
return results;
}
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
myList.clear();
myList.addAll((List<Product>) results.values);
notifyDataSetChanged();
}
};
}
stdin_in -> file_out [label=<<font color="blue">tee >/dev/null</font>>];
应该是标签的文本,但是它包含tee >/dev/null
,这是一个特殊字符,因此>
对此有所抱怨。我该怎么办?谢谢。