Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //initialize the ACTV
- AutoCompleteTextView search = (AutoCompleteTextView) findViewById(R.id.actvCatalogueSearch);
- search.setThreshold(1); //set threshold
- //experiment time!!
- //I honestly don't know what this is for
- int[] to = { android.R.id.text1 };
- //initializing the cursorAdapter.
- //please note that pdflist is the array I used for the ACTV value
- SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this,
- android.R.layout.simple_dropdown_item_1line, null, pdflist, to, 0);
- cursorAdapter.setStringConversionColumn(1);
- //FilterQueryProvider here
- FilterQueryProvider provider = new FilterQueryProvider(){
- @Override
- public Cursor runQuery(CharSequence constraint) {
- // TODO Auto-generated method stub
- Log.d("hi", "runQuery constraint: " + constraint);
- if (constraint == null) {
- return null;
- }
- String[] columnNames = { Columns._ID, "name" };
- MatrixCursor c = new MatrixCursor(columnNames);
- try {
- //loop through the array, then when an array element contains the constraint, add.
- for (int i = 0; i < pdflist.length; i++) {
- if(pdflist[i].contains(constraint)){
- c.newRow().add(i).add(pdflist[i]);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return c;
- }
- };
- cursorAdapter.setFilterQueryProvider(provider);
- search.setAdapter(cursorAdapter);
- requesting column name with table name -- <first element of array here>
- .....
- java.lang.IllegalArugmentException: column <first element of array here> does not exist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement