AutoCompleteTextView 实现自定义匹配规则提示

原文地址:http://blog.csdn.net/adreamer_bj/article/details/6321234

AutoCompleteTextView 在做搜索功能时常常被应用到,它的好处是根据用户输入的信息实现后缀信息的提示功能。

此控件通常的用法是 

  1. ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line, COUNTRIES);  
  2.         AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);  
  3.         textView.setAdapter(adapter);  

其中 adapter 可以任意构造, COUNTRIES 是数据源,如 COUNTTRIES=["aaaaa","bbbbbb","cccccc"], 那么当在框中输入a时,则AutoCompleteTextView 自动提示aaaaa,这种根据数据源的值来提示做起来很是简单,略过。

下面讲一下自定义匹配规则的提示,假如现在有这么一个需求,根据输入城市的拼音,来提示相对应的城市列表,这样就不能按上述方式来做了,因为你输入的信息并不是数据源的信息,所以你必须得自定义匹配规则来找出对应的城市提示,思路是这样的:先把所有的城市及对应的拼音放在一个Hashtable里,然后自己实现一个 Adapter 来加载这些数据源,当用户输入每一个拼音字符时,需实时监听到(系统主动监听),然后去Hashtable里找到对应的城市设置到Adapter里,这样在控件的下拉列表中就可以看到所需的城市列表提示,我贴一段 Adapter代码供大家参考一下,定义了一个SearchCityAdapter extends BaseAdapter implements Filterable,其中Filterable接口主要是用来实现自定义匹配规则的,它定义了getFilter()方法

[java]  view plain copy print ?
  1. public Filter getFilter() {  
  2.         if (mFilter == null) {  
  3.             mFilter = new CityArrayFilter();  
  4.         }  
  5.         return mFilter;  
  6.     }  
 

此方法是为了得到一个过滤器,也就是自定义匹配规则的过滤器即CityArrayFilter,它的实现是

[java]  view plain copy print ?
  1. /** 
  2.      * <p>An array filter constrains the content of the array adapter with 
  3.      * a prefix. Each item that does not start with the supplied prefix 
  4.      * is removed from the list.</p> 
  5.      */  
  6.     private class CityArrayFilter extends Filter {  
  7.         /** 
  8.          * The method is called when receive softkeybord entry's char  
  9.          */  
  10.         @Override  
  11.         protected FilterResults performFiltering(CharSequence prefix) {  
  12.             if(Log.DEBUG.get()) {  
  13.                 Log.i(tag, "CityArrayFilter : performFiltering >>>>>>>>>>> prefix = "+prefix);  
  14.             }  
  15.               
  16.             FilterResults results = new FilterResults();  
  17.             if (mOriginalValues == null) {  
  18.                 synchronized (mLock) {  
  19.                     mOriginalValues = new ArrayList<T>(mObjects);  
  20.                 }  
  21.             }  
  22.             if (prefix == null || prefix.length() == 0) {  
  23.                 synchronized (mLock) {  
  24.                     ArrayList<T> list = new ArrayList<T>(mOriginalValues);  
  25.                     results.values = list;  
  26.                     results.count = list.size();  
  27.                 }  
  28.             } else {  
  29.                 String prefixString = prefix.toString().toLowerCase();  
  30.                 final ArrayList<T> values = mOriginalValues;  
  31.                 final int count = values.size();  
  32.                 final ArrayList<T> newValues = new ArrayList<T>(count);  
  33.                 final Enumeration enumeration = ChooseCityActivity.ht.keys();   
  34.                 String key;  
  35.                 String[] keyPart;  
  36.                 while(enumeration.hasMoreElements()) {  
  37.                     key = (String)enumeration.nextElement();  
  38.                     keyPart = key.split("-");  
  39.                     Log.i(tag, ">>>>>>>>>>>>>>>>>>> prefixString = "+prefixString+" key = "+key);  
  40.                     if(prefixString.length() == 1 && keyPart[1].startsWith(prefixString)) {  
  41.                         newValues.add((T)ChooseCityActivity.ht.get(key));  
  42.                     } else if (prefixString.length() == 2) {  
  43.                         if(keyPart[2].equals(prefixString)) {  
  44.                             newValues.add((T)ChooseCityActivity.ht.get(key));  
  45.                         }  
  46.                         if(newValues.size() == 0 && keyPart[1].startsWith(prefixString)) {  
  47.                             newValues.add((T)ChooseCityActivity.ht.get(key));  
  48.                         }  
  49.                     } else if (prefixString.length() == 3) {  
  50.                         if(keyPart[0].equals(prefixString)) {  
  51.                             newValues.add((T)ChooseCityActivity.ht.get(key));  
  52.                         }  
  53.                         if(newValues.size() == 0 && keyPart[1].startsWith(prefixString)) {  
  54.                             newValues.add((T)ChooseCityActivity.ht.get(key));  
  55.                         }  
  56.                     }  
  57.                 }  
  58.                 /*for (int i = 0; i < count; i++) { 
  59.                     final T value = values.get(i); 
  60.                     final String valueText = value.toString().toLowerCase(); 
  61.                     // First match against the whole, non-splitted value 
  62.                     if (valueText.startsWith(prefixString)) { 
  63.                         newValues.add(value); 
  64.                     }else { 
  65.                         final String[] words = valueText.split(" "); 
  66.                         final int wordCount = words.length; 
  67.                         for (int k = 0; k < wordCount; k++) { 
  68.                             if (words[k].startsWith(prefixString)) { 
  69.                                 newValues.add(value); 
  70.                                 break; 
  71.                             } 
  72.                         } 
  73.                     } 
  74.                 }*/  
  75.                 results.values = newValues;  
  76.                 results.count = newValues.size();  
  77.             }  
  78.             return results;  
  79.         }  
  80.         @Override  
  81.         protected void publishResults(CharSequence constraint, FilterResults results) {  
  82.             if(Log.DEBUG.get()) {  
  83.                 Log.i(tag, "CityArrayFilter : publishResults >>>>>>>>>>> results.values = "+results.values);  
  84.             }  
  85.             mObjects = (List<T>) results.values;  
  86.             if (results.count > 0) {  
  87.                 notifyDataSetChanged();  
  88.             } else {  
  89.                 notifyDataSetInvalidated();  
  90.             }  
  91.         }  
  92.     }  
 

while()里是匹配规则,FilterResults 装的是匹配后的城市,最终它将作为 getView() 的数据源显示在AutoCompleteTextView 的下拉列表里,prefix 指的是监听到的用户输入的拼音字符,通过这个字符去Hashtable里查找对应的城市,具体描述请看看下面的Adapter的完整代码

[java]  view plain copy print ?
  1. public class SearchCityAdapter<T> extends BaseAdapter implements Filterable {  
  2.     private static final String tag = Log.getTag(SearchCityAdapter.class);  
  3.     /** 
  4.      * Contains the list of objects that represent the data of this ArrayAdapter. 
  5.      * The content of this list is referred to as "the array" in the documentation. 
  6.      */  
  7.     private List<T> mObjects;  
  8.     /** 
  9.      * Lock used to modify the content of {@link #mObjects}. Any write operation 
  10.      * performed on the array should be synchronized on this lock. This lock is also 
  11.      * used by the filter (see {@link #getFilter()} to make a synchronized copy of 
  12.      * the original array of data. 
  13.      */  
  14.     private final Object mLock = new Object();  
  15.     /** 
  16.      * The resource indicating what views to inflate to display the content of this 
  17.      * array adapter. 
  18.      */  
  19.     private int mResource;  
  20.     /** 
  21.      * The resource indicating what views to inflate to display the content of this 
  22.      * array adapter in a drop down widget. 
  23.      */  
  24.     private int mDropDownResource;  
  25.     /** 
  26.      * If the inflated resource is not a TextView, {@link #mFieldId} is used to find 
  27.      * a TextView inside the inflated views hierarchy. This field must contain the 
  28.      * identifier that matches the one defined in the resource file. 
  29.      */  
  30.     private int mFieldId = 0;  
  31.     /** 
  32.      * Indicates whether or not {@link #notifyDataSetChanged()} must be called whenever 
  33.      * {@link #mObjects} is modified. 
  34.      */  
  35.     private boolean mNotifyOnChange = true;  
  36.     private Context mContext;  
  37.     private ArrayList<T> mOriginalValues;  
  38.     private CityArrayFilter mFilter;  
  39.     private LayoutInflater mInflater;  
  40.     /** 
  41.      * Constructor 
  42.      * 
  43.      * @param context The current context. 
  44.      * @param textViewResourceId The resource ID for a layout file containing a TextView to use when 
  45.      *                 instantiating views. 
  46.      */  
  47.     public SearchCityAdapter(Context context, int textViewResourceId) {  
  48.         init(context, textViewResourceId, 0new ArrayList<T>());  
  49.     }  
  50.     /** 
  51.      * Constructor 
  52.      * 
  53.      * @param context The current context. 
  54.      * @param resource The resource ID for a layout file containing a layout to use when 
  55.      *                 instantiating views. 
  56.      * @param textViewResourceId The id of the TextView within the layout resource to be populated 
  57.      */  
  58.     public SearchCityAdapter(Context context, int resource, int textViewResourceId) {  
  59.         init(context, resource, textViewResourceId, new ArrayList<T>());  
  60.     }  
  61.     /** 
  62.      * Constructor 
  63.      * 
  64.      * @param context The current context. 
  65.      * @param textViewResourceId The resource ID for a layout file containing a TextView to use when 
  66.      *                 instantiating views. 
  67.      * @param objects The objects to represent in the ListView. 
  68.      */  
  69.     public SearchCityAdapter(Context context, int textViewResourceId, T[] objects) {  
  70.         init(context, textViewResourceId, 0, Arrays.asList(objects));  
  71.     }  
  72.     /** 
  73.      * Constructor 
  74.      * 
  75.      * @param context The current context. 
  76.      * @param resource The resource ID for a layout file containing a layout to use when 
  77.      *                 instantiating views. 
  78.      * @param textViewResourceId The id of the TextView within the layout resource to be populated 
  79.      * @param objects The objects to represent in the ListView. 
  80.      */  
  81.     public SearchCityAdapter(Context context, int resource, int textViewResourceId, T[] objects) {  
  82.         init(context, resource, textViewResourceId, Arrays.asList(objects));  
  83.     }  
  84.     /** 
  85.      * Constructor 
  86.      * 
  87.      * @param context The current context. 
  88.      * @param textViewResourceId The resource ID for a layout file containing a TextView to use when 
  89.      *                 instantiating views. 
  90.      * @param objects The objects to represent in the ListView. 
  91.      */  
  92.     public SearchCityAdapter(Context context, int textViewResourceId, List<T> objects) {  
  93.         init(context, textViewResourceId, 0, objects);  
  94.     }  
  95.     /** 
  96.      * Constructor 
  97.      * 
  98.      * @param context The current context. 
  99.      * @param resource The resource ID for a layout file containing a layout to use when 
  100.      *                 instantiating views. 
  101.      * @param textViewResourceId The id of the TextView within the layout resource to be populated 
  102.      * @param objects The objects to represent in the ListView. 
  103.      */  
  104.     public SearchCityAdapter(Context context, int resource, int textViewResourceId, List<T> objects) {  
  105.         init(context, resource, textViewResourceId, objects);  
  106.     }  
  107.     /** 
  108.      * Adds the specified object at the end of the array. 
  109.      * 
  110.      * @param object The object to add at the end of the array. 
  111.      */  
  112.     public void add(T object) {  
  113.         if (mOriginalValues != null) {  
  114.             synchronized (mLock) {  
  115.                 mOriginalValues.add(object);  
  116.                 if (mNotifyOnChange) notifyDataSetChanged();  
  117.             }  
  118.         } else {  
  119.             mObjects.add(object);  
  120.             if (mNotifyOnChange) notifyDataSetChanged();  
  121.         }  
  122.     }  
  123.     /** 
  124.      * Adds the specified Collection at the end of the array. 
  125.      * 
  126.      * @param collection The Collection to add at the end of the array. 
  127.      */  
  128.     public void addAll(Collection<? extends T> collection) {  
  129.         if (mOriginalValues != null) {  
  130.             synchronized (mLock) {  
  131.                 mOriginalValues.addAll(collection);  
  132.                 if (mNotifyOnChange) notifyDataSetChanged();  
  133.             }  
  134.         } else {  
  135.             mObjects.addAll(collection);  
  136.             if (mNotifyOnChange) notifyDataSetChanged();  
  137.         }  
  138.     }  
  139.     /** 
  140.      * Adds the specified items at the end of the array. 
  141.      * 
  142.      * @param items The items to add at the end of the array. 
  143.      */  
  144.     public void addAll(T ... items) {  
  145.         if (mOriginalValues != null) {  
  146.             synchronized (mLock) {  
  147.                 for (T item : items) {  
  148.                     mOriginalValues.add(item);  
  149.                 }  
  150.                 if (mNotifyOnChange) notifyDataSetChanged();  
  151.             }  
  152.         } else {  
  153.             for (T item : items) {  
  154.                 mObjects.add(item);  
  155.             }  
  156.             if (mNotifyOnChange) notifyDataSetChanged();  
  157.         }  
  158.     }  
  159.     /** 
  160.      * Inserts the specified object at the specified index in the array. 
  161.      * 
  162.      * @param object The object to insert into the array. 
  163.      * @param index The index at which the object must be inserted. 
  164.      */  
  165.     public void insert(T object, int index) {  
  166.         if (mOriginalValues != null) {  
  167.             synchronized (mLock) {  
  168.                 mOriginalValues.add(index, object);  
  169.                 if (mNotifyOnChange) notifyDataSetChanged();  
  170.             }  
  171.         } else {  
  172.             mObjects.add(index, object);  
  173.             if (mNotifyOnChange) notifyDataSetChanged();  
  174.         }  
  175.     }  
  176.     /** 
  177.      * Removes the specified object from the array. 
  178.      * 
  179.      * @param object The object to remove. 
  180.      */  
  181.     public void remove(T object) {  
  182.         if (mOriginalValues != null) {  
  183.             synchronized (mLock) {  
  184.                 mOriginalValues.remove(object);  
  185.             }  
  186.         } else {  
  187.             mObjects.remove(object);  
  188.         }  
  189.         if (mNotifyOnChange) notifyDataSetChanged();  
  190.     }  
  191.     /** 
  192.      * Remove all elements from the list. 
  193.      */  
  194.     public void clear() {  
  195.         if (mOriginalValues != null) {  
  196.             synchronized (mLock) {  
  197.                 mOriginalValues.clear();  
  198.             }  
  199.         } else {  
  200.             mObjects.clear();  
  201.         }  
  202.         if (mNotifyOnChange) notifyDataSetChanged();  
  203.     }  
  204.     /** 
  205.      * Sorts the content of this adapter using the specified comparator. 
  206.      * 
  207.      * @param comparator The comparator used to sort the objects contained 
  208.      *        in this adapter. 
  209.      */  
  210.     public void sort(Comparator<? super T> comparator) {  
  211.         Collections.sort(mObjects, comparator);  
  212.         if (mNotifyOnChange) notifyDataSetChanged();  
  213.     }  
  214.     /** 
  215.      * {@inheritDoc} 
  216.      */  
  217.     @Override  
  218.     public void notifyDataSetChanged() {  
  219.         super.notifyDataSetChanged();  
  220.         mNotifyOnChange = true;  
  221.     }  
  222.     /** 
  223.      * Control whether methods that change the list ({@link #add}, 
  224.      * {@link #insert}, {@link #remove}, {@link #clear}) automatically call 
  225.      * {@link #notifyDataSetChanged}.  If set to false, caller must 
  226.      * manually call notifyDataSetChanged() to have the changes 
  227.      * reflected in the attached view. 
  228.      * 
  229.      * The default is true, and calling notifyDataSetChanged() 
  230.      * resets the flag to true. 
  231.      * 
  232.      * @param notifyOnChange if true, modifications to the list will 
  233.      *                       automatically call {@link 
  234.      *                       #notifyDataSetChanged} 
  235.      */  
  236.     public void setNotifyOnChange(boolean notifyOnChange) {  
  237.         mNotifyOnChange = notifyOnChange;  
  238.     }  
  239.     private void init(Context context, int resource, int textViewResourceId, List<T> objects) {  
  240.         mContext = context;  
  241.         mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
  242.         mResource = mDropDownResource = resource;  
  243.         mObjects = objects;  
  244.         mFieldId = textViewResourceId;  
  245.         for (T t : objects) {  
  246.             Log.i(tag, ">>>>>>>>>>>>> t = "+t);  
  247.         }  
  248.     }  
  249.     /** 
  250.      * Returns the context associated with this array adapter. The context is used 
  251.      * to create views from the resource passed to the constructor. 
  252.      * 
  253.      * @return The Context associated with this adapter. 
  254.      */  
  255.     public Context getContext() {  
  256.         return mContext;  
  257.     }  
  258.     /** 
  259.      * {@inheritDoc} 
  260.      */  
  261.     public int getCount() {  
  262.         return mObjects.size();  
  263.     }  
  264.     /** 
  265.      * {@inheritDoc} 
  266.      */  
  267.     public T getItem(int position) {  
  268.         return mObjects.get(position);  
  269.     }  
  270.     /** 
  271.      * Returns the position of the specified item in the array. 
  272.      * 
  273.      * @param item The item to retrieve the position of. 
  274.      * 
  275.      * @return The position of the specified item. 
  276.      */  
  277.     public int getPosition(T item) {  
  278.         return mObjects.indexOf(item);  
  279.     }  
  280.     /** 
  281.      * {@inheritDoc} 
  282.      */  
  283.     public long getItemId(int position) {  
  284.         return position;  
  285.     }  
  286.     /** 
  287.      * {@inheritDoc} 
  288.      */  
  289.     public View getView(int position, View convertView, ViewGroup parent) {  
  290.         return createViewFromResource(position, convertView, parent, mResource);  
  291.     }  
  292.     private View createViewFromResource(int position, View convertView, ViewGroup parent,  
  293.             int resource) {  
  294.         View view;  
  295.         TextView text;  
  296.         if (convertView == null) {  
  297.             view = mInflater.inflate(resource, parent, false);  
  298.         } else {  
  299.             view = convertView;  
  300.         }  
  301.         try {  
  302.             if (mFieldId == 0) {  
  303.                 //  If no custom field is assigned, assume the whole resource is a TextView  
  304.                 text = (TextView) view;  
  305.             } else {  
  306.                 //  Otherwise, find the TextView field within the layout  
  307.                 text = (TextView) view.findViewById(mFieldId);  
  308.             }  
  309.         } catch (ClassCastException e) {  
  310.             Log.e("SearchCityAdapter""You must supply a resource ID for a TextView");  
  311.             throw new IllegalStateException(  
  312.                     "SearchCityAdapter requires the resource ID to be a TextView", e);  
  313.         }  
  314.         T item = getItem(position);  
  315.         Log.i(tag, ">>>>>>>>>>>>>> position = "+position+" item = "+item);  
  316.         if (item instanceof CharSequence) {  
  317.             text.setText((CharSequence)item);  
  318.         } else {  
  319.             text.setText(item.toString());  
  320.         }  
  321.         return view;  
  322.     }  
  323.     /** 
  324.      * <p>Sets the layout resource to create the drop down views.</p> 
  325.      * 
  326.      * @param resource the layout resource defining the drop down views 
  327.      * @see #getDropDownView(int, android.view.View, android.view.ViewGroup) 
  328.      */  
  329.     public void setDropDownViewResource(int resource) {  
  330.         this.mDropDownResource = resource;  
  331.     }  
  332.     /** 
  333.      * {@inheritDoc} 
  334.      */  
  335.     @Override  
  336.     public View getDropDownView(int position, View convertView, ViewGroup parent) {  
  337.         return createViewFromResource(position, convertView, parent, mDropDownResource);  
  338.     }  
  339.     /** 
  340.      * Creates a new ArrayAdapter from external resources. The content of the array is 
  341.      * obtained through {@link android.content.res.Resources#getTextArray(int)}. 
  342.      * 
  343.      * @param context The application's environment. 
  344.      * @param textArrayResId The identifier of the array to use as the data source. 
  345.      * @param textViewResId The identifier of the layout used to create views. 
  346.      * 
  347.      * @return An ArrayAdapter<CharSequence>. 
  348.      */  
  349.     public static ArrayAdapter<CharSequence> createFromResource(Context context,  
  350.             int textArrayResId, int textViewResId) {  
  351.         CharSequence[] strings = context.getResources().getTextArray(textArrayResId);  
  352.         return new ArrayAdapter<CharSequence>(context, textViewResId, strings);  
  353.     }  
  354.     /** 
  355.      * {@inheritDoc} 
  356.      */  
  357.     public Filter getFilter() {  
  358.         if (mFilter == null) {  
  359.             mFilter = new CityArrayFilter();  
  360.         }  
  361.         return mFilter;  
  362.     }  
  363.     /** 
  364.      * <p>An array filter constrains the content of the array adapter with 
  365.      * a prefix. Each item that does not start with the supplied prefix 
  366.      * is removed from the list.</p> 
  367.      */  
  368.     private class CityArrayFilter extends Filter {  
  369.         /** 
  370.          * The method is called when receive softkeybord entry's char  
  371.          */  
  372.         @Override  
  373.         protected FilterResults performFiltering(CharSequence prefix) {  
  374.             if(Log.DEBUG.get()) {  
  375.                 Log.i(tag, "CityArrayFilter : performFiltering >>>>>>>>>>> prefix = "+prefix);  
  376.             }  
  377.               
  378.             FilterResults results = new FilterResults();  
  379.             if (mOriginalValues == null) {  
  380.                 synchronized (mLock) {  
  381.                     mOriginalValues = new ArrayList<T>(mObjects);  
  382.                 }  
  383.             }  
  384.             if (prefix == null || prefix.length() == 0) {  
  385.                 synchronized (mLock) {  
  386.                     ArrayList<T> list = new ArrayList<T>(mOriginalValues);  
  387.                     results.values = list;  
  388.                     results.count = list.size();  
  389.                 }  
  390.             } else {  
  391.                 String prefixString = prefix.toString().toLowerCase();  
  392.                 final ArrayList<T> values = mOriginalValues;  
  393.                 final int count = values.size();  
  394.                 final ArrayList<T> newValues = new ArrayList<T>(count);  
  395.                 final Enumeration enumeration = ChooseCityActivity.ht.keys();   
  396.                 String key;  
  397.                 String[] keyPart;  
  398.                 while(enumeration.hasMoreElements()) {  
  399.                     key = (String)enumeration.nextElement();  
  400.                     keyPart = key.split("-");  
  401.                     Log.i(tag, ">>>>>>>>>>>>>>>>>>> prefixString = "+prefixString+" key = "+key);  
  402.                     if(prefixString.length() == 1 && keyPart[1].startsWith(prefixString)) {  
  403.                         newValues.add((T)ChooseCityActivity.ht.get(key));  
  404.                     } else if (prefixString.length() == 2) {  
  405.                         if(keyPart[2].equals(prefixString)) {  
  406.                             newValues.add((T)ChooseCityActivity.ht.get(key));  
  407.                         }  
  408.                         if(newValues.size() == 0 && keyPart[1].startsWith(prefixString)) {  
  409.                             newValues.add((T)ChooseCityActivity.ht.get(key));  
  410.                         }  
  411.                     } else if (prefixString.length() == 3) {  
  412.                         if(keyPart[0].equals(prefixString)) {  
  413.                             newValues.add((T)ChooseCityActivity.ht.get(key));  
  414.                         }  
  415.                         if(newValues.size() == 0 && keyPart[1].startsWith(prefixString)) {  
  416.                             newValues.add((T)ChooseCityActivity.ht.get(key));  
  417.                         }  
  418.                     }  
  419.                 }  
  420.                 /*for (int i = 0; i < count; i++) { 
  421.                     final T value = values.get(i); 
  422.                     final String valueText = value.toString().toLowerCase(); 
  423.                     // First match against the whole, non-splitted value 
  424.                     if (valueText.startsWith(prefixString)) { 
  425.                         newValues.add(value); 
  426.                     }else { 
  427.                         final String[] words = valueText.split(" "); 
  428.                         final int wordCount = words.length; 
  429.                         for (int k = 0; k < wordCount; k++) { 
  430.                             if (words[k].startsWith(prefixString)) { 
  431.                                 newValues.add(value); 
  432.                                 break; 
  433.                             } 
  434.                         } 
  435.                     } 
  436.                 }*/  
  437.                 results.values = newValues;  
  438.                 results.count = newValues.size();  
  439.             }  
  440.             return results;  
  441.         }  
  442.         @Override  
  443.         protected void publishResults(CharSequence constraint, FilterResults results) {  
  444.             if(Log.DEBUG.get()) {  
  445.                 Log.i(tag, "CityArrayFilter : publishResults >>>>>>>>>>> results.values = "+results.values);  
  446.             }  
  447.             mObjects = (List<T>) results.values;  
  448.             if (results.count > 0) {  
  449.                 notifyDataSetChanged();  
  450.             } else {  
  451.                 notifyDataSetInvalidated();  
  452.             }  
  453.         }  
  454.     }  
  455. }  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值