List of usage examples for android.support.v4.widget SimpleCursorAdapter getCount
public int getCount()
From source file:Main.java
public static void setSpinnerSelectionById(Spinner spinner, int itemId) { SimpleCursorAdapter adapter = (SimpleCursorAdapter) spinner.getAdapter(); for (int position = 0; position < adapter.getCount(); position++) { if (adapter.getItemId(position) == itemId) { spinner.setSelection(position); return; }/*from w w w . java 2 s.co m*/ } spinner.setSelection(0); }
From source file:com.enadein.carlogbook.ui.BaseLogAcivity.java
protected int getPositionFromAdapterById(SimpleCursorAdapter adapter, long id) { int position = 0; for (int i = 0; i < adapter.getCount(); i++) { long currentId = adapter.getItemId(i); if (currentId == id) { position = i;//from w ww .j a v a 2s . c om break; } } return position; }
From source file:au.com.cybersearch2.classyfy.MainActivityTest.java
public void test_search() throws Throwable { final MainActivity mainActivity = getActivity(); Instrumentation instrumentation = getInstrumentation(); ActivityMonitor am = instrumentation.addMonitor(TitleSearchResultsActivity.class.getName(), null, false); assertThat(instrumentation.invokeMenuActionSync(mainActivity, R.id.action_search, 0)).isTrue(); ActionBar actionBar = mainActivity.getSupportActionBar(); assertThat(actionBar).isNotNull();//from w ww .java 2s. c o m final FragmentManager sfm = mainActivity.getSupportFragmentManager(); runTestOnUiThread(new Runnable() { public void run() { sfm.executePendingTransactions(); } }); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_I); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_N); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_F); instrumentation.sendCharacterSync(KeyEvent.KEYCODE_ENTER); runTestOnUiThread(new Runnable() { public void run() { sfm.executePendingTransactions(); } }); TitleSearchResultsActivity titleSearchResultsActivity = (TitleSearchResultsActivity) getInstrumentation() .waitForMonitorWithTimeout(am, 10000); assertThat(titleSearchResultsActivity).isNotNull(); assertThat(titleSearchResultsActivity.taskHandle).isNotNull(); synchronized (titleSearchResultsActivity.taskHandle) { titleSearchResultsActivity.taskHandle.wait(10000); } assertThat(titleSearchResultsActivity.taskHandle.getStatus()).isEqualTo(WorkStatus.FINISHED); SimpleCursorAdapter adapter = titleSearchResultsActivity.adapter; for (int i = 0; i < adapter.getCount(); i++) { Cursor cursor = (Cursor) adapter.getItem(i); int column = cursor.getColumnIndexOrThrow(SearchManager.SUGGEST_COLUMN_TEXT_1); assertThat(INF_LIST[i]).isEqualTo(cursor.getString(column)); } }
From source file:bander.notepad.NoteListAppCompat.java
@Override public void onResume() { super.onResume(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); boolean largeListItems = preferences.getBoolean("listItemSize", true); int sortOrder = Integer.valueOf(preferences.getString("sortOrder", "1")); boolean sortAscending = preferences.getBoolean("sortAscending", true); String sorting = Note.SORT_ORDERS[sortOrder] + ((sortAscending ? " ASC" : " DESC")); Cursor cursor = getContentResolver().query(getIntent().getData(), PROJECTION, null, null, sorting); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, (largeListItems) ? R.layout.row_large_appcompat : R.layout.row_small_appcompat, cursor, new String[] { Note.TITLE }, new int[] { android.R.id.text1 }, 0); setListAdapter(adapter);//from ww w . j ava 2 s . c o m getListView().setOnItemClickListener(this); if ((!GIVEN_HINT) && (adapter.getCount() == 1)) { Toast.makeText(this, R.string.hint_longpress, Toast.LENGTH_LONG).show(); GIVEN_HINT = true; } }