private void setAdapter(Cursor cursor) { if (mLv.getAdapter() == null) { SimpleCursorAdapter adapter = new SimpleCursorAdapter(SearchViewActivity2.this, R.layout.item_layout, cursor, new String[]{"name"}, new int[]{R.id.text1}); mLv.setAdapter(adapter); } else { ((SimpleCursorAdapter) mLv.getAdapter()).changeCursor(cursor); } } }
private void initEvent() { mMySQLite = new MySQLite(this); mDbReader = mMySQLite.getReadableDatabase(); mSimpleCursorAdapter = new SimpleCursorAdapter(MyListActivity.this, R.layout.listview_sql_item, null, new String[] { MySQLite.KEY_logOutput, MySQLite.KEY_timestamp }, new int[] { R.id.logoutput, R.id.timestamp }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); mListView.setAdapter(mSimpleCursorAdapter); refresh(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_lista_contatos); final ListView listView = (ListView) findViewById(br.com.livroandroid.contatos.R.id.listView); listView.setOnItemClickListener(this); // Lista os contatos Uri contatos = ContactsContract.Contacts.CONTENT_URI; Cursor cursor = getContentResolver().query(contatos, null, ContactsContract.Contacts.HAS_PHONE_NUMBER +" = 1 ", null, ContactsContract.Contacts.DISPLAY_NAME); // Não temos como jogar a foto aqui SimpleCursorAdapter adapter = new SimpleCursorAdapter( getBaseContext(), R.layout.adapter_contato, cursor, new String[]{ContactsContract.Contacts.DISPLAY_NAME}, new int[]{R.id.tNome}, 0); listView.setAdapter(adapter); Toast.makeText(this, "Com o SimpleCursorAdapter diretamente não conseguimos mostrar a foto.", Toast.LENGTH_SHORT).show(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String[] columns = new String[]{ SampleContentProvider.Person.AGE, SampleContentProvider.Person.NAME}; int[] ids = { R.id.person_age, R.id.person_name}; adapter = new SimpleCursorAdapter(this, R.layout.person_item, null, columns, ids, 0); ((ListView) findViewById(R.id.list_view)).setAdapter(adapter); findViewById(R.id.add).setOnClickListener(this); findViewById(R.id.delete).setOnClickListener(this); getSupportLoaderManager().initLoader(0, null, this); }
/** * Creates a cursor adapter given a {@link List<SearchResult>}. * https://stackoverflow.com/questions/11628172/converting-an-arrayadapter-to-cursoradapter-for-use-in-a-searchview/11628527#11628527 * * @param results the results to be placed in the adapter. * @return the adapter. */ public static CursorAdapter getCursorAdapter(Context context, List<SearchResult> results) { int id = 0; MatrixCursor cursor = new MatrixCursor(columnNames); for (SearchResult item : results) { String[] temp = new String[2]; temp[0] = String.valueOf(id); // "_id" temp[1] = item.getPageName(); // "title" cursor.addRow(temp); id++; } return new SimpleCursorAdapter( context, R.layout.search_suggestions_list_item, cursor, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER ); } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "onStartCommand"); mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); mMySQLite = new MySQLite(this); mDbWriter = mMySQLite.getWritableDatabase(); mDbReader = mMySQLite.getReadableDatabase(); mSimpleCursorAdapter = new SimpleCursorAdapter(this, R.layout.listview_sql_item, null, new String[] { "songname", "singer" }, new int[] { R.id.logoutput, R.id.timestamp }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); String command = intent.getStringExtra(COMMAND); if (command != null) { if (command.equals(COMMAND_OPEN)) { openFPS(); } else if (command.equals(COMMAND_CLOSE)) { closeFPS(); } } return super.onStartCommand(intent, flags, startId); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mp3); mPrgDuracao = (ProgressBar) findViewById(R.id.progressBar); mTxtMusica = (TextView) findViewById(R.id.txtMusica); mTxtDuracao = (TextView) findViewById(R.id.txtTempo); int[] componentes = new int[]{ android.R.id.text1, android.R.id.text2 }; mAdapter = new SimpleCursorAdapter( this, android.R.layout.simple_list_item_2, null, colunas, componentes, 0); }
private void initSuggestionData(Cursor cursor) { mSearchView.setSuggestionsAdapter(new SimpleCursorAdapter(getContext(), R.layout.item_search_suggestion, cursor, new String[] {"keyWord"}, new int[] {R.id.txt_sug}, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER)); mSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { cursor.moveToPosition(position); mSearchView.setQuery(cursor.getString(cursor.getColumnIndex("keyWord")), true); mSearchView.clearFocus(); if (!cursor.isClosed()) { cursor.close(); } return true; } }); }
adapter = new SimpleCursorAdapter( (Context)this, R.layout.blockinger_list_item,
String[] from = {DbContract.CategoryEntry.COLUMN_NAME}; int[] to = {R.id.text1}; adapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.simple_spinner_item, c, from, to, CursorAdapter.FLAG_AUTO_REQUERY); adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);
String[] from = {DbContract.CategoryEntry.COLUMN_NAME}; int[] to = {R.id.text1}; adapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.simple_spinner_item, c, from, to, CursorAdapter.FLAG_AUTO_REQUERY); adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);
String[] from = {DbContract.CategoryEntry.COLUMN_NAME}; int[] to = {R.id.text1}; adapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.simple_spinner_item, c, from, to, CursorAdapter.FLAG_AUTO_REQUERY); adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);
String[] from = {DbContract.CategoryEntry.COLUMN_NAME}; int[] to = {R.id.text1}; adapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.simple_spinner_item, c, from, to, CursorAdapter.FLAG_AUTO_REQUERY); adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);
streamActvAdapter = new SimpleCursorAdapter( that, R.layout.stream_tile, null, new String[]{Stream.NAME_FIELD}, subjectActvAdapter = new SimpleCursorAdapter( that, R.layout.stream_tile, null, new String[]{Message.SUBJECT_FIELD}, emailActvAdapter = new SimpleCursorAdapter( that, R.layout.stream_tile, null, new String[]{Person.EMAIL_FIELD},
private void initAutoComplete() { mHistory.open(); String[] from = new String[] { HistoryOpenHelper.COLUMN_REALM }; int[] to = new int[] { android.R.id.text1 }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_dropdown_item_1line, null, from, to, 0); // Set the CursorToStringConverter, to provide the labels for the // choices to be displayed in the AutoCompleteTextView. adapter.setCursorToStringConverter(new CursorToStringConverter() { public String convertToString(android.database.Cursor cursor) { final int columnIndex = cursor .getColumnIndexOrThrow(HistoryOpenHelper.COLUMN_REALM); return cursor.getString(columnIndex); } }); // Set the FilterQueryProvider, to run queries for choices // that match the specified input. adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { String partialInput = (constraint != null ? constraint .toString() : ""); return mHistory.getHistoryCursor(partialInput); } }); mSiteAddress.setAdapter(adapter); }
String[] from = {DbContract.CategoryEntry.COLUMN_NAME}; int[] to = {R.id.item_name}; list.setAdapter(new SimpleCursorAdapter(getBaseContext(), R.layout.item_category, DbAccess.getCategoriesWithoutDefault(getBaseContext()), from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER)); list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); list.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
SimpleCursorAdapter ringtoneAdapter = new SimpleCursorAdapter(context, singleChoiceItemLayout, mCursor, new String[]{MediaStore.Audio.Media.TITLE}, new int[]{android.R.id.text1});
}; mAdapter = new SimpleCursorAdapter(getActivity().getBaseContext(), R.layout.sessionlistfragment, null, from, to, 0); mAdapter.setViewBinder(new SessionViewBinder());
streamActv.setOnFocusChangeListener(focusChangeListener); SimpleCursorAdapter combinedAdapter = new SimpleCursorAdapter( that, R.layout.emoji_tile, null, new String[]{Emoji.NAME_FIELD, Emoji.NAME_FIELD},