Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. //initialize the ACTV
  2. AutoCompleteTextView search = (AutoCompleteTextView) findViewById(R.id.actvCatalogueSearch);
  3. search.setThreshold(1); //set threshold
  4.  
  5. //experiment time!!
  6.  
  7. //I honestly don't know what this is for
  8. int[] to = { android.R.id.text1 };
  9.  
  10. //initializing the cursorAdapter.
  11. //please note that pdflist is the array I used for the ACTV value
  12. SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this,
  13. android.R.layout.simple_dropdown_item_1line, null, pdflist, to, 0);
  14.  
  15. cursorAdapter.setStringConversionColumn(1);
  16.  
  17. //FilterQueryProvider here
  18. FilterQueryProvider provider = new FilterQueryProvider(){
  19. @Override
  20. public Cursor runQuery(CharSequence constraint) {
  21. // TODO Auto-generated method stub
  22. Log.d("hi", "runQuery constraint: " + constraint);
  23. if (constraint == null) {
  24. return null;
  25. }
  26. String[] columnNames = { Columns._ID, "name" };
  27. MatrixCursor c = new MatrixCursor(columnNames);
  28.  
  29. try {
  30. //loop through the array, then when an array element contains the constraint, add.
  31. for (int i = 0; i < pdflist.length; i++) {
  32. if(pdflist[i].contains(constraint)){
  33. c.newRow().add(i).add(pdflist[i]);
  34. }
  35. }
  36. } catch (Exception e) {
  37. e.printStackTrace();
  38. }
  39. return c;
  40. }
  41. };
  42.  
  43. cursorAdapter.setFilterQueryProvider(provider);
  44. search.setAdapter(cursorAdapter);
  45.  
  46. requesting column name with table name -- <first element of array here>
  47. .....
  48. java.lang.IllegalArugmentException: column <first element of array here> does not exist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement