Java Code Examples for android.widget.SimpleCursorAdapter#setCursorToStringConverter()

The following examples show how to use android.widget.SimpleCursorAdapter#setCursorToStringConverter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Collins.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param context this
 * @param layout  support_simple_spinner_dropdown_item
 * @return
 */
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout,
                    null,
                    new String[]{FIELD_HWD},
                    new int[]{android.R.id.text1},
                    0
            );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return getFilterCursor(constraint.toString());
                }
            }
    );
    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
 
Example 2
Source File: WebsterLearners.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout,
                    null,
                    new String[]{"hwd"},
                    new int[]{android.R.id.text1},
                    0
            );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return getFilterCursor(constraint.toString());
                }
            }
    );
    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
 
Example 3
Source File: Ode2.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param context this
 * @param layout  support_simple_spinner_dropdown_item
 * @return
 */
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout,
                    null,
                    new String[]{FIELD_HWD},
                    new int[]{android.R.id.text1},
                    0
            );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return getFilterCursor(constraint.toString());
                }
            }
    );
    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
 
Example 4
Source File: CollinsEnEn.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param context this
 * @param layout  support_simple_spinner_dropdown_item
 * @return
 */
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout,
                    null,
                    new String[]{FIELD_HWD},
                    new int[]{android.R.id.text1},
                    0
            );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return getFilterCursor(constraint.toString());
                }
            }
    );
    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}
 
Example 5
Source File: CustomDictionary.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
    SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(context, layout, null,
                    new String[] {ExternalDatabase.getHeadwordColumnName()},
                    new int[] {android.R.id.text1},
                    0
                    );
    adapter.setFilterQueryProvider(
            new FilterQueryProvider() {
                @Override
                public Cursor runQuery(CharSequence constraint) {
                    return mDatabase.getFilterCursor(mDictId, constraint.toString());
                }
            }
    );

    adapter.setCursorToStringConverter(
            new SimpleCursorAdapter.CursorToStringConverter() {
                @Override
                public CharSequence convertToString(Cursor cursor) {
                    return cursor.getString(1);
                }
            }
    );

    return adapter;
}