List of usage examples for android.database Cursor moveToPosition
boolean moveToPosition(int position);
From source file:com.example.ami1.CheckActivity.java
@Override public void onItemClicked(int position) { // Get the cursor from the adapter final Cursor cursor = mAdapter.getCursor(); cursor.moveToPosition(position); // get the uri final Uri labelUri = Uri.parse(cursor.getString(cursor.getColumnIndex(GmailContract.Labels.URI))); Log.i(TAG, "got label uri: " + labelUri); final Intent intent = new Intent(this, LabelDetailsActivity.class); intent.putExtra(LabelDetailsActivity.LABEL_URI_EXTRA, labelUri); startActivity(intent);// w ww .java 2 s . co m }
From source file:com.vagabond.dealhunting.ui.SearchActivity.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Cursor cursor = mResultsAdapter.getCursor(); cursor.moveToPosition(position); Uri dealUri = DealContract.PromotionEntry.buildPromotionUri(cursor.getInt(COLUMN_PROMOTION_ID_INDEX)); Intent intent = new Intent(this, DetailActivity.class); intent.setData(dealUri);//from w w w. j a v a 2 s . co m startActivity(intent); }
From source file:can.yrt.onebusaway.MyStopListFragmentBase.java
private void showOnMap(ListView l, int position) { // Get the cursor and fetch the stop ID from that. SimpleCursorAdapter cursorAdapter = (SimpleCursorAdapter) l.getAdapter(); Cursor c = cursorAdapter.getCursor(); c.moveToPosition(position - l.getHeaderViewsCount()); final String stopId = c.getString(COL_ID); final double lat = c.getDouble(COL_LATITUDE); final double lon = c.getDouble(COL_LONGITUDE); HomeActivity.start(getActivity(), stopId, lat, lon); }
From source file:com.jpventura.alexandria.ListOfBooks.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { Cursor cursor = bookListAdapter.getCursor(); if ((null == cursor) || !cursor.moveToPosition(position)) return;//from w w w .ja va 2s . c om String ean = cursor.getString(cursor.getColumnIndex(AlexandriaContract.BookEntry._ID)); ((Callback) getActivity()).onItemSelected(ean); }
From source file:org.totschnig.myexpenses.fragment.AccountList.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.accounts_list, null, false); ListView lv = (ListView) v.findViewById(R.id.list); // Create an array to specify the fields we want to display in the list String[] from = new String[] { "description", "label", "opening_balance", "sum_income", "sum_expenses", "sum_transfer", "current_balance" }; // and an array of the fields we want to bind those fields to int[] to = new int[] { R.id.description, R.id.label, R.id.opening_balance, R.id.sum_income, R.id.sum_expenses, R.id.sum_transfer, R.id.current_balance }; // Now create a simple cursor adapter and set it to display mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.account_row, null, from, to, 0) { @Override/*from w w w . ja va 2 s.co m*/ public View getView(int position, View convertView, ViewGroup parent) { View row = super.getView(position, convertView, parent); Cursor c = getCursor(); c.moveToPosition(position); int col = c.getColumnIndex("currency"); Currency currency = Utils.getSaveInstance(c.getString(col)); View v = row.findViewById(R.id.color1); v.setBackgroundColor(c.getInt(c.getColumnIndex("color"))); setConvertedAmount((TextView) row.findViewById(R.id.opening_balance), currency); setConvertedAmount((TextView) row.findViewById(R.id.sum_income), currency); setConvertedAmount((TextView) row.findViewById(R.id.sum_expenses), currency); setConvertedAmount((TextView) row.findViewById(R.id.sum_transfer), currency); setConvertedAmount((TextView) row.findViewById(R.id.current_balance), currency); col = c.getColumnIndex("description"); String description = c.getString(col); if (description.equals("")) row.findViewById(R.id.description).setVisibility(View.GONE); return row; } }; getLoaderManager().initLoader(0, null, this); lv.setAdapter(mAdapter); lv.setEmptyView(v.findViewById(R.id.empty)); //requires using activity (ManageAccounts) to implement OnItemClickListener lv.setOnItemClickListener((OnItemClickListener) getActivity()); registerForContextMenu(lv); return v; }
From source file:com.DGSD.Teexter.UI.Recipient.RecipientAlternatesAdapter.java
public RecipientEntry getRecipientEntry(int position) { Cursor c = getCursor(); c.moveToPosition(position); return RecipientEntry.constructTopLevelEntry(c.getString(EmailQuery.NAME), c.getString(EmailQuery.ADDRESS), c.getInt(EmailQuery.ADDRESS_TYPE), c.getString(EmailQuery.ADDRESS_LABEL), c.getLong(EmailQuery.CONTACT_ID), c.getLong(EmailQuery.DATA_ID), c.getString(EmailQuery.PHOTO_THUMBNAIL_URI)); }
From source file:com.andremion.louvre.data.MediaLoader.java
/** * Add "All Media" item as the first row of bucket items. * * @param cursor The original data of all bucket items * @return The data with "All Media" item added *//* www . j ava 2 s. co m*/ private Cursor addAllMediaBucketItem(@Nullable Cursor cursor) { if (cursor == null || !cursor.moveToPosition(0)) { return null; } ensureActivityAttached(); long id = ALL_MEDIA_BUCKET_ID; String label = mActivity.getString(R.string.activity_gallery_bucket_all_media); String data = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA)); MatrixCursor allMediaRow = new MatrixCursor(BUCKET_PROJECTION); allMediaRow.newRow().add(id).add(label).add(data); return new MergeCursor(new Cursor[] { allMediaRow, cursor }); }
From source file:com.android.theguardian.NewsFragment.java
@Override protected void initData() { mNewsAdapter = new NewsAdapter(getActivity(), null, 0); mListView.setAdapter(mNewsAdapter);/*from w w w . j a v a 2s .co m*/ mListView.setVisibility(View.VISIBLE); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setRefreshing(true); onRefresh(); TheguardianSyncAdapter.syncImmediately(getActivity(), title); getLoaderManager().initLoader(0, null, this); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Cursor cursor = mNewsAdapter.getCursor(); cursor.moveToPosition(position); String webUrl = cursor.getString(cursor.getColumnIndex(NewsContract.NewsEntry.COLUMN_WEB_URL)); Intent detailIntent = new Intent(getActivity(), DetailActivity.class); detailIntent.putExtra("web_url", webUrl); startActivity(detailIntent); } }); }
From source file:com.idt.ontomedia.geoconsum.fragments.GeoconsumListFragment.java
@Override public void onListItemClick(ListView _listView, View _view, int _position, long _id) { super.onListItemClick(_listView, _view, _position, _id); Cursor cursor = mCursorAdapter.getCursor(); if ((cursor != null) && (!cursor.isClosed())) { cursor.moveToPosition(_position); Intent intent = new Intent(); intent.setClass(mParentActivity, mDestinationActivityClass); intent.putExtra(EXTRA_ID_KEY, cursor.getInt(cursor.getColumnIndex(DatabaseAdapter.COLUMN_ROWID))); startActivity(intent);//from w w w. j a va 2 s .co m } }
From source file:com.zns.comicdroid.adapter.ComicAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { Cursor cursor = getCursor(); if (cursor.moveToPosition(position)) { ComicHolder holder;//from w ww. j a v a 2 s .c o m if (convertView == null) { convertView = mLayoutInflater.inflate(mLayout, null); holder = new ComicHolder(); holder.tvTitle = (TextView) convertView.findViewById(R.id.tvTitle); holder.tvAuthor = (TextView) convertView.findViewById(R.id.tvAuthor); holder.ivImage = (ImageView) convertView.findViewById(R.id.ivImage); holder.tvIssue = (TextView) convertView.findViewById(R.id.tvIssue); holder.rlRow = (RelativeLayout) convertView.findViewById(R.id.rlRow); holder.rbComic = (RatingBar) convertView.findViewById(R.id.rbComicList); convertView.setTag(holder); } else { holder = (ComicHolder) convertView.getTag(); } String title = cursor.getString(1); String subTitle = cursor.getString(2); if (subTitle == null) subTitle = ""; String author = cursor.getString(3); String image = cursor.getString(4); int issue = cursor.getInt(5); boolean isBorrowed = cursor.getInt(6) == 1; //boolean isRead = cursor.getInt(7) == 1; int rating = cursor.getInt(8); String strTitle = title + (subTitle.length() > 0 ? " - " + subTitle : ""); if (!mRenderTitle) strTitle = subTitle.length() > 0 ? subTitle : title; holder.tvTitle.setText(strTitle); holder.tvAuthor.setText(author); if (issue > 0) { holder.tvIssue.setText("Vol. " + Integer.toString(issue)); } else { holder.tvIssue.setText(""); } if (image != null && !image.equals("")) { ImageLoader.getInstance().displayImage(mImagePath.concat(image), holder.ivImage); holder.ivImage.setVisibility(View.VISIBLE); } else { holder.ivImage.setVisibility(View.GONE); } if (isBorrowed) { holder.rlRow.setBackgroundColor(mColorIsBorrowed); } else { holder.rlRow.setBackgroundColor(mColorDefault); } holder.rbComic.setVisibility(rating > 0 ? View.VISIBLE : View.GONE); holder.rbComic.setRating(rating); } return convertView; }