List of usage examples for android.support.v4.widget SimpleCursorAdapter SimpleCursorAdapter
public SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags)
From source file:de.hshannover.f4.trust.ironcontrol.view.list_activities.ListSavedConnectionsActivity.java
private void initListAdapter() { String[] from = new String[] { Connections.COLUMN_NAME, Connections.COLUMN_ADDRESS, Connections.COLUMN_USER, Connections.COLUMN_DEFAULT }; int[] to = new int[] { R.id.tvLabel, R.id.tvServer_address, R.id.tvServerUser, R.id.tvDefault }; adapter = new SimpleCursorAdapter(this, R.layout.connection_row, null, from, to, 0); adapter.setViewBinder(buildViewBinder()); setListAdapter(adapter);//www . jav a 2s. com }
From source file:com.concavenp.nanodegree.popularmoviesimproved.MovieListingFragment.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Set the layout for this fragment View view = inflater.inflate(R.layout.fragment_movieitem_grid, container, false); mFlipper = view.findViewById(R.id.movies_ViewFlipper); ////////////////////////////////////////// // view 1 of 2 in the flipper - the favorite movies ////////////////////////////////////////// // Create the adapter to link data from the DB to our specified item (result_item) mFavoritesAdapter = new SimpleCursorAdapter(getActivity(), R.layout.favorites_item, null, FROM, TO, 0); VIEW_BINDER.setListener(mListener);//from w w w . j ava2 s .c o m mFavoritesAdapter.setViewBinder(VIEW_BINDER); GridView gridView = mFlipper.findViewById(R.id.main_favorite_movies_GridView); // Set the adapter gridView.setAdapter(mFavoritesAdapter); ////////////////////////////////////////// // view 2 of 2 in the flipper - the popular/voted movies ////////////////////////////////////////// RecyclerView recyclerView = mFlipper.findViewById(R.id.main_Movies_GridView); mAdapter = new MovieAdapter(mListener); recyclerView.setAdapter(mAdapter); GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), getResources().getInteger(R.integer.number_of_columns)); recyclerView.setLayoutManager(gridLayoutManager); mScrollListener = new EndlessRecyclerOnScrollListener(gridLayoutManager) { @Override public void onLoadMore(int current_page) { requestData(current_page); } }; recyclerView.addOnScrollListener(mScrollListener); // use this setting to improve performance if you know that changes // in content do not change the layout size of the RecyclerView recyclerView.setHasFixedSize(true); ////////////////////////////////////////// return view; }
From source file:com.enadein.carlogbook.ui.AddUpdateLogActivity.java
@Override protected void postCreate() { unitFacade = getMediator().getUnitFacade(); odometerView = (EditText) findViewById(R.id.odometer); priceView = (EditText) findViewById(R.id.price); nameView = (EditText) findViewById(R.id.name); commentView = (EditText) findViewById(R.id.comment); typeSpinner = (Spinner) findViewById(R.id.typeSpinner); ohterTypeSpinner = (Spinner) findViewById(R.id.ohterTypeSpinner); typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override//from ww w. j av a2 s.c o m public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long l) { findViewById(R.id.otherGroup).setVisibility(pos == 0 ? View.VISIBLE : View.GONE); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); // final Cursor c = getContentResolver().query(ProviderDescriptor.DataValue.CONTENT_URI, null, null, null, null); String[] from = new String[] { ProviderDescriptor.DataValue.Cols.NAME }; int[] to = new int[] { android.R.id.text1 }; otherTypesApater = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, null, from, to, SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); otherTypesApater.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); ohterTypeSpinner.setAdapter(otherTypesApater); updateLabels(); }
From source file:org.openbmap.activities.WifiListContainer.java
private void initData() { final DataHelper dataHelper = new DataHelper(getActivity()); mSession = dataHelper.getActiveSessionId(); final String[] from = new String[] { Schema.COL_ID, Schema.COL_BSSID, Schema.COL_SSID, "MAX(" + Schema.COL_LEVEL + ")", /*Schema.COL_IS_NEW_WIFI,*/ Schema.COL_KNOWN_WIFI, Schema.COL_CAPABILITIES }; final int[] to = new int[] { R.id.wifilistfragment_id, R.id.wifilistfragment_bssid, R.id.wifilistfragment_ssid, R.id.wifilistfragment_level, R.id.wifilistfragment_statusicon, R.id.wifilistfragment_capabilities }; mAdapter = new SimpleCursorAdapter(getActivity().getBaseContext(), R.layout.wifilistitems, null, from, to, 0);/*from w w w . j a v a2s.c om*/ mAdapter.setViewBinder(new WifiViewBinder()); setListAdapter(mAdapter); }
From source file:monakhv.android.samlib.AuthorListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String[] from = { SQLController.COL_NAME, SQLController.COL_mtime, SQLController.COL_isnew, SQLController.COL_TGNAMES, SQLController.COL_URL }; int[] to = { R.id.authorName, R.id.updated, R.id.icon, R.id.tgnames, R.id.authorURL }; adapter = new SimpleCursorAdapter(getActivity(), R.layout.rowlayout, null, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); SettingsHelper settings = new SettingsHelper(getActivity().getApplicationContext()); adapter.setViewBinder(new AuthorViewBinder()); order = settings.getAuthorSortOrder(); setListAdapter(adapter);/*from w w w . j a va 2 s .co m*/ getLoaderManager().initLoader(AUTHOR_LIST_LOADER, null, this); detector = new GestureDetector(getActivity(), new ListSwipeListener(this)); }
From source file:com.hplasplas.weather.activitys.SearchPlaceActivity.java
private void createSuggestionAdapter() { if (mSearchView.getSuggestionsAdapter() == null) { int[] to = { R.id.city_item, R.id.country }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(SearchPlaceActivity.this, R.layout.city_search_item, null, COLUMNS_PLACE_NAME, to, 0); mSearchView.setSuggestionsAdapter(adapter); }//from w w w . j a v a2s . c om }
From source file:com.dgsd.android.ShiftTracker.Fragment.EditShiftFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_edit_shift, container, false); mName = (StatefulAutoCompleteTextView) v.findViewById(R.id.name); mNotes = (StatefulEditText) v.findViewById(R.id.notes); mPayRate = (StatefulEditText) v.findViewById(R.id.pay_rate); mUnpaidBreak = (StatefulEditText) v.findViewById(R.id.unpaid_break); mStartDate = (TextView) v.findViewById(R.id.start_date); mEndDate = (TextView) v.findViewById(R.id.end_date); mStartTime = (TextView) v.findViewById(R.id.start_time); mEndTime = (TextView) v.findViewById(R.id.end_time); mSaveAsTemplate = (CheckBox) v.findViewById(R.id.is_template); mReminders = v.findViewById(R.id.reminders); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getActivity(), R.layout.reminders_spinner_item, mRemindersLabels); adapter.setDropDownViewResource(R.layout.reminders_spinner_dropdown_item); setAdapter(mReminders, adapter);//from w ww. ja va 2 s . co m if (StApp.isFreeApp(getActivity())) { mReminders.setEnabled(false); mReminders.setClickable(false); ViewGroup parent = ((ViewGroup) mReminders.getParent()); parent.setClickable(true); parent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mLinkToPaidAppFragment != null && mLinkToPaidAppFragment.isResumed()) return; //Already showing mLinkToPaidAppFragment = LinkToPaidAppFragment .newInstance(getString(R.string.reminders_unavailable_message)); mLinkToPaidAppFragment.show(getSherlockActivity().getSupportFragmentManager(), null); } }); } mStartDate.setOnClickListener(this); mEndDate.setOnClickListener(this); mStartTime.setOnClickListener(this); mEndTime.setOnClickListener(this); mNameAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1, null, new String[] { DbField.NAME.name }, new int[] { android.R.id.text1 }, 0); mNameAdapter.setStringConversionColumn(0);//Index of 'Name' column mName.setAdapter(mNameAdapter); mName.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mName.setError(null); mLastNameFilter = mName.getText() == null ? null : mName.getText().toString(); getLoaderManager().restartLoader(LOADER_ID_NAMES, null, EditShiftFragment.this); } }); mUnpaidBreak.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { mUnpaidBreak.setError(null); } }); return v; }
From source file:de.hshannover.f4.trust.ironcontrol.view.list_activities.ListSavedPublishsActivity.java
private void fillData() { String[] from = new String[] { Requests.COLUMN_NAME, Requests.COLUMN_IDENTIFIER1, Requests.COLUMN_METADATA };//from w ww . j a v a 2s.c o m int[] to = new int[] { R.id.label, R.id.label_info1, R.id.label_info2 }; getLoaderManager().initLoader(0, null, this); adapter = new SimpleCursorAdapter(this, R.layout.publish_list_row, null, from, to, 0); setListAdapter(adapter); }
From source file:com.teocci.utubinbg.MainActivity.java
/** * Options menu in action bar//from w w w . j a v a 2 s.co m * * @param menu * @return */ @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView != null) { searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); } //suggestions final CursorAdapter suggestionAdapter = new SimpleCursorAdapter(this, R.layout.dropdown_menu, null, new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1 }, new int[] { android.R.id.text1 }, 0); final List<String> suggestions = new ArrayList<>(); searchView.setSuggestionsAdapter(suggestionAdapter); searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { searchView.setQuery(suggestions.get(position), false); searchView.clearFocus(); Intent suggestionIntent = new Intent(Intent.ACTION_SEARCH); suggestionIntent.putExtra(SearchManager.QUERY, suggestions.get(position)); handleIntent(suggestionIntent); return true; } }); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { return false; //if true, no new intent is started } @Override public boolean onQueryTextChange(String suggestion) { // check network connection. If not available, do not query. // this also disables onSuggestionClick triggering if (suggestion.length() > 2) { //make suggestions after 3rd letter if (networkConf.isNetworkAvailable()) { new JsonAsyncTask(new JsonAsyncTask.AsyncResponse() { @Override public void processFinish(ArrayList<String> result) { suggestions.clear(); suggestions.addAll(result); String[] columns = { BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1 }; MatrixCursor cursor = new MatrixCursor(columns); for (int i = 0; i < result.size(); i++) { String[] tmp = { Integer.toString(i), result.get(i) }; cursor.addRow(tmp); } suggestionAdapter.swapCursor(cursor); } }).execute(suggestion); return true; } } return false; } }); return true; }
From source file:com.esri.arcgisruntime.sample.findaddress.MainActivity.java
/** * Sets up the address SearchView. Uses MatrixCursor to show suggestions to the user as the user inputs text. *///w w w . ja v a2s .c om private void setupAddressSearchView() { mAddressGeocodeParameters = new GeocodeParameters(); // get place name and address attributes mAddressGeocodeParameters.getResultAttributeNames().add("PlaceName"); mAddressGeocodeParameters.getResultAttributeNames().add("StAddr"); // return only the closest result mAddressGeocodeParameters.setMaxResults(1); mAddressSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String address) { // geocode typed address geoCodeTypedAddress(address); // clear focus from search views mAddressSearchView.clearFocus(); return true; } @Override public boolean onQueryTextChange(String newText) { // as long as newText isn't empty, get suggestions from the locatorTask if (!newText.equals("")) { final ListenableFuture<List<SuggestResult>> suggestionsFuture = mLocatorTask .suggestAsync(newText); suggestionsFuture.addDoneListener(new Runnable() { @Override public void run() { try { // get the results of the async operation List<SuggestResult> suggestResults = suggestionsFuture.get(); MatrixCursor suggestionsCursor = new MatrixCursor(mColumnNames); int key = 0; // add each address suggestion to a new row for (SuggestResult result : suggestResults) { suggestionsCursor.addRow(new Object[] { key++, result.getLabel() }); } // define SimpleCursorAdapter String[] cols = new String[] { COLUMN_NAME_ADDRESS }; int[] to = new int[] { R.id.suggestion_address }; final SimpleCursorAdapter suggestionAdapter = new SimpleCursorAdapter( MainActivity.this, R.layout.suggestion, suggestionsCursor, cols, to, 0); mAddressSearchView.setSuggestionsAdapter(suggestionAdapter); // handle an address suggestion being chosen mAddressSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { // get the selected row MatrixCursor selectedRow = (MatrixCursor) suggestionAdapter .getItem(position); // get the row's index int selectedCursorIndex = selectedRow.getColumnIndex(COLUMN_NAME_ADDRESS); // get the string from the row at index String address = selectedRow.getString(selectedCursorIndex); // use clicked suggestion as query mAddressSearchView.setQuery(address, true); return true; } }); } catch (Exception e) { Log.e(TAG, "Geocode suggestion error: " + e.getMessage()); } } }); } return true; } }); }