android-cursoradapter

Using CursorLoader with LoaderManager to retrieve images from android apps

谁说我不能喝 提交于 2019-11-28 14:08:52
At the moment I’m using getContentResolver().query()/managedQuery() to get a cursor to retrieve images from the gallery app. Because the APIs I’m using are partly deprecated I wanted to use CursorLoader with LoaderManager. /** * Creates a cursor to access the content defined by the image uri for API * version 11 and newer. * * @return The created cursor. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private Cursor createCursorHoneycomb() { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(imageUri, projection, null, null, null); return cursor; }

Android - Prevent text truncation in SearchView suggestions?

℡╲_俬逩灬. 提交于 2019-11-28 11:21:44
The suggestions that appear in the default ListView beneath my SearchView contain text that is truncated. I would like the text to be displayed in its entirety (on multiple lines if necessary). I have come up with two possible ways to solve this but, with no examples to be found on the net, I was hoping someone on here may be able to help... Approach #1 / Q1: How can I directly access and modify the appearance of the TextViews that hold the SUGGEST_COLUMN_TEXT_1 and SUGGEST_COLUMN_TEXT_1 text? Approach #2 / Q2: Alternatively, SearchView has a setSuggestionsAdapter(CursorAdapter adapter) method

ORMLite with CursorAdapter in Android

醉酒当歌 提交于 2019-11-28 09:13:03
I am modifying my Android app to work with ORMLite, and it currently uses a number of CursorAdapters, which I quite want to keep in an attempt to minimise coding. I'm not 100% sure but t appears that when ORMLite creates an id field in the db, it always uses id , whereas CursorAdapter needs _id . It is possible to get round this using a query like the following: select id as _id ...... but the Dao.queryRaw() method returns a list, not a Cursor, so the way I have done it is to open another SQLiteOpenHelper database connection and use rawQuery() . This works, but are there any better ways of

How to remove a selected item from ListView using CursorAdapter

无人久伴 提交于 2019-11-28 08:41:49
I am using CursorAdapter and below is my adapter class. My list consists of two text views and one button on each row. Now, on click of the button I want to delete the selected item from the list as well as from the database. How can I get the id of the selected item from the database so that I can delete it and then notify the adapter (refresh the list). public class MyAdapter extends CursorAdapter { Cursor c; LayoutInflater inflater; Context context; private String TAG = getClass().getSimpleName(); public MyAdapter(Context context, Cursor c) { super(context, c); this.c = c; this.context =

ListView using two cursoradapters?

十年热恋 提交于 2019-11-28 06:56:22
I have some code which executes two queries against a database and returns two cursor objects. Is there any way that I can combine these two cursors so that all the ListView gets the data from both? yanchenko There's MergeCursor for that (if there's no way to join tables). FYI - An example of using MergeCursor() c = Cursor containing Contacts columns from Contacts.CONTENT_URI private Cursor mergeCursorSubset(Cursor c) { int userMobile = ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE, workMobile = ContactsContract.CommonDataKinds.Phone.TYPE_WORK_MOBILE; String storedNumber =

Android - Is ViewHolder pattern automatically implemented in CursorAdapter?

若如初见. 提交于 2019-11-28 05:19:09
I always use ViewHolder pattern in my custom ArrayAdapter classes. However, in CursorAdapter the getView() method is not mandatory required to be overridden , but has the bindView and newView methods. My question is - does CursorAdapter re-uses views by internally implementing the ViewHolder pattern or it needs to be coded as we normally do in custom ArrayAdapter ? If it needs to be coded, what is the correct way to do it? Update I'm using android.support.v4.widget.CursorAdapter My question is - does CursorAdapter re-uses views by internally implementing the ViewHolder pattern or it needs to

Android: how to use CursorAdapter?

倾然丶 夕夏残阳落幕 提交于 2019-11-28 03:36:33
I have a database, a ListView , and a CustomCursorAdapter that extends CursorAdapter . A menu button adds an item to the database. I want the ListView to update and show this change. Normally it doesn't show this new item until i go to the homescreen and reopen the application. I did eventually get it to work by calling cursor.requery() or mCustomCursorAdapter.changeCursor(newCursor) whenever I added a new item, but when I set autoRequery to false in the CursorAdapter constructor, it worked just the same. Why does it update correctly when autoRequery is set to false? Am I using CursorAdapter

MultiAutoCompleteTextView with contacts phone numbers

放肆的年华 提交于 2019-11-28 02:17:34
I need to create a MultiAutoCompleteTextView with the phone numbers of the contacts on a user's device. What I need is similar to gmail; except with gmail email addresses are used. For the contacts, I have the following needs: each phone number must be an entry. So if John has 3 numbers (home, cell, work), they show as 3 entries each entry is searchable by phone number or by first/last name of person To create my adapter, I try to modify the one provided by Google but when I download the sample, it does not compile (kind of a crappy experience when the thing is right out of the box, but I am

SimpleCursorAdapter how to show an image?

流过昼夜 提交于 2019-11-27 22:37:28
I am making an android recipes application where i use a database. In database there is a column named" "images", where i store the name of the file of the picture of the recipe where i store at drawable folder. Now i want to make a List with the recipes, showing: 1) the Title of the recipe 2) a short description and 3) an image of the recipe To do that i use a Simplecursoradaptor. My problem is i can not show the image. I want to read the file name from the column "images" and then set the image at my imageview (R.id.imageview1) Here is my code untill now: public class RecipesMainActivity

What bindView() and newView() do in CursorAdapter

筅森魡賤 提交于 2019-11-27 17:44:20
I have a custom CursorAdaptor in my project with overridden methods bindView(View view, Context context, Cursor cursor) and newView(View view, Context context, Cursor cursor) . I want to know for what CursorAdapter are used for and what is the difference between and uses of overriding bindView() and newView() . I have read the Developer Site and this tutorial but still I didn't understood. As I'm a beginner to Android, please help me understand this concept. Vinay S Shenoy In order to understand this, you must first understand how BaseAdapter works, since CursorAdapter is a subclass of