1

I've made this code:

 public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    View view = inflater.inflate(R.layout.fragment_search, container, false);
    Button search = (Button)view.findViewById(R.id.cerca);
    andata = (AutoCompleteTextView)view.findViewById(R.id.andata);
    ritorno = (AutoCompleteTextView)view.findViewById(R.id.ritorno);
    //set adapters

    ParseQuery<ParseObject>query = ParseQuery.getQuery("Stations");

    query.findInBackground(new FindCallback<ParseObject>()
    {
        @Override
        public void done(List<ParseObject> list, ParseException e)
        {
            if(e == null)
            {
                for(int i = 0; i<list.size();i++)
                {
                    String name = list.get(i).getString("code");
                    StationNames.add(name);

                }

                String [] strAdapter = new String[StationNames.size()];
                strAdapter=StationNames.toArray(strAdapter);
                ArrayAdapter<String>adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,strAdapter);
                andata.setAdapter(adapter);
                ritorno.setAdapter(adapter);

            }
            else
            {
              e.printStackTrace();
            }

        }
    });

and the problem is that there are 50k stations to download from Parse..my question is: it's possible to start this download after 3 character written? For example after digit "Pin" the query to Parse starts... Thank you

ste9206
  • 1,822
  • 4
  • 31
  • 47
  • 1
    see `setThreshold` – pskink May 25 '16 at 07:33
  • @pskink in xml or java? – ste9206 May 25 '16 at 07:34
  • I put android:completionThreshold="3" in xml.. so I don't change anything in the query, sure? – ste9206 May 25 '16 at 07:41
  • 1
    basically there is no need to download 50k stations and keep it in array adapter, it is simply waste of memory, you should query each time you type something in your `ACTV`, see [here](http://stackoverflow.com/a/19860624/2252830) for a complete working code – pskink May 25 '16 at 07:43
  • but if I use threshold(3) it download 50k in the same mode? – ste9206 May 25 '16 at 07:51
  • 1
    threshold has nothing to do with your 50k download, just do not download all the stations but only those that match the text entered in `ACTV` – pskink May 25 '16 at 07:54
  • I see your link but I don't understand how to do a Filter in the query, for example "Milan" station.. i would start query when user digits "Mil"..I have to receive this "Mil" from ACTV and do in query ".whereEqualTo("code","Mil"); ? – ste9206 May 25 '16 at 08:13
  • do you see `runQuery` method? it has `CharSequence constraint` parameter holding your "Mil" string, now you can call a query that returns all the data starting (or containing) that string, i have no experience with `ParseQuery` though – pskink May 25 '16 at 08:16

0 Answers0