Android :: Way To Deal With CursorAdapter - Switching Contacts API?
Nov 5, 2010Does anyone tried to use CursorAdapter with old and new api?
Do you have some code examples of such solutions?
Does anyone tried to use CursorAdapter with old and new api?
Do you have some code examples of such solutions?
I've altered the contact app so that in Dialer the soft keypad always stays and it hides when other tab activity resumes, We've given different look for the contacts app, but when using the same, a crash occurs when we rapidly change from dialer to call log. And the App crashes without the standard crash dialog.
View 1 Replies View RelatedDoes the CursorAdapter run on a background thread and posts updates via the UI looper thread? If not what is the best pattern to load data asynchronously from a ContentProvider?
View 1 Replies View RelatedI am writing my own ContentProvider for my own application. And there is a ListView with a CursorAdapter pulling data from my Content Provider. My question is when there is a data change in my ContentProvider, how can I notify my CursorAdatper to requery the data and then have the ListView updated?
View 2 Replies View RelatedI'm watching this video http://www.youtube.com/watch?v=N6YdwzAvwOA and Romain Guy is showing how to make more efficient UI adapter code using the getView() method. Does this apply to CursorAdapters as well? I'm currently using bindView() and newView() for my custom cursor adapters. Should I be using getView instead?
View 1 Replies View RelatedI was using some of the code from DeskClock and found that when I tried to modify the CursorAdapter that newView was getting called for each item. (I actually wanted to add a divider and it seems like adding the dividers separately is better than adding them into a single listView)
If I have 3 items I get the following behavior:
CODE:.............
I would've expected newView/bindView to be called once per cursor item. But, that doesn't seem to be the case. This was kind of a problem for me because I wanted to select the appropriate view depending on the cursor data, but since bindView could be called before newView that doesn't work.
Is this some odd recycler behavior (or somehow normal/expected)? Or is there something broken with the code (I removed everything except the ListView and it's still doing this)? I'm not quite sure why you would try to bind views that haven't been created, and why newView gets called on the first item twice.
If someone has an easy way of adding dividers to ListViews I'd love to know. I was going to try to dig through the contacts example to see how they did it there if not.
In case anyone's wondering MergeAdapter was neat to mess around with and try (I'll use it in some other situations). But, I did just end up writing a single adapter that handles multiple views. It computes the type of each item (which is small), stores it in a map, initializes it at adapter creation, and updates it in notifyDataSetChanged.
Then you just need to have getViewTypeCount() return the number of possible views. And getItemViewType to return the type from the map (which is 0 based, so 0-getViewTypeCount()). If you can compute your type from the position you don't need the map, but doing this on the fly wasn't possible so I just pre/recompute when needed.
I have a list view with 2 buttons on each row. I am using a cursoradpater to populate the list. I am also using the view holder pattern on newview() bindview().
My questions are: where do i put the clicklisteners for the buttons knowing that the action for the button is different from the action of the list item itself? Do i keep the onListItemClick ?
I am building a custom listview used to list contacts from the contact cursor into a list with two text view for the phone number and name of the contact as well as a place for the images. I am getting a nullpoint error when i try to setText for my TextView Even though i checked the variable to see if they contained a string I have no ideas whats wrong with it. Code...
View 1 Replies View RelatedI have a cursor adapter and the logcat is filled with above errors, as soon as I click on a view. I am already releasing the CursorAdapter's cursor in onDestroy().Is there any way to get information about when the cursor was opened?
View 3 Replies View RelatedI have a CursorAdapter attached to a ListView, the ListView contains checkboxes for every row. When I check/uncheck a checkbox in a row it will update it to a 0 or 1 in the database (This is working fine) I also have another checkbox in the same Activity that when pressed will disable all the checkboxes in the ListView [ setEnabled(false) ].
The problem is that when I press this checkbox the ListView checkboxes return to their initial state when I started the activity. It does not matter the number of checkboxes I changed during the activity.
However, if I press the back button and then re-enter the activity all modifications are saved because the Cursor is refreshed. I am calling notifyDataSetChanged() at the end of the the methods that disables all the checkboxes.
I also tried this for every checkbox in the ListView but it did not work (was unable to check a checkbox) Any ideas?
I have a ListView backed by a custom adapter based on a CursorAdapter.The cursor I give it is based on a list of Notes in the database (each note is a DB row).Everything works just fine until I delete a note from the database. I'm not sure how to properly update the cursor/adapter/listview to display the new data.I've read conflicting posts on using adapter.notifyDataSetChanged() vs cursor.requery() to refresh the UI, but neither of them seems to work in this case.The only way I've been able to refresh it is by creating a new cursor from a new query and calling adapter.changeCursor(newCursor).Could someone demonstrate the proper way to update the backing data and then the UI (with psuedocode if possible).
View 2 Replies View RelatedI have a listactivity as a startup screen in my application. Which is displaying database records using custom cursor adapter. On create I set the filterable flag - getListView().setTextFilterEnabled(true)
My cursoradapter overrides runQueryOnBackgroundThread which runs corresponding query. The problem is that after typing some text and hitting enter, runQueryOnBackgroundThread never gets called. However, when the item click in the same view launches another activity(detail view of the record) and I come back to the original list activity, hitting back button, then text filtering works just fine. I don't call setTextFilterEnabled anywhere except during the initialization process and I can't really find any other API affecting this behavior, so any guesses why text filtering doesn't work initially, but all of the sudden starts working when I come back to the list activity from child activity?
I'm trying to clean up some code and now I'm determined to get this seemless ListView updating working...
I want my ListView to be updated when I call notifyDataSetChanged() but nothing happens... I'm also passing the autoRequery flag to true when creating my CursorAdapter.
Cursor c = FavoritesHandler.getCategoryFavorites(getSQLiteInstance(), category); m_favoriteAdapter.changeCursor(c); startManagingCursor(c);
I am essentially using a listview but am looking at providing a bookmark functionality. I am thinking that I should store the item attributes in a file when bookmarked and retrieve when required to populate a bookmark listview.
I was wondering if there is a de facto standard used in achieving this or do I follow just the "writing into a file" and "reading from a file" when necessary style?
We want to add below update sql into our content provider:We found current update of content provider does not support it, which would not recognize the "column1" of "column1 + 1" as column name. So we have to add execSQL method into ContentProvider and I think it is dirt. So I wonder if anyone know how to do such thing with ContentProvider or any more elegant way to achieve it.
View 5 Replies View RelatedMy application needs to intensively manipulate (read-write) on some structured text data.The size of the data is significant 1Mb. And there is initial data available for the user to start with.My idea is to put this data as a file in the .apk. Then, on initial application launch to read this data and populate Android SQLite database with it. Then just work with this database. But after the database is populated the data file is no longer needed. And I'd like to remove it to free some memory. Alternate approach is to work with this data file instead of SQLite database. But I assume SQLite would work a magnitude faster then i/o on my data file..
View 16 Replies View RelatedI write a listactivty,the item including a textview and a button,the data came from a sqlite。but in handling the clickevent , i meet some problem, in the CursorAdapter's bindView() function,i cann't get the current position。in log,i find position of Cursor is the position I last click the item of listview.
The code as follows: package miaozl.hello;
CODE:............................
I want to create an app widget that could take up a different number of "cells" on the home screen, but I don't think that the app widget framework easily supports this. I know that an app widget can have a configuration screen, and I'd like the user to be able select a sort of small, medium, or large size for the widget as part of my configuration activity. Unfortunately, I don't think that this is possible, correct? Based on the minWidth and minHeight properties, the Launcher app will assign a number of cells that I can't configure at run time.
For instance, if I want a weather widget that has a current, hourly and weekly format that take up 1, 2, and 4 cells respectively, I can't do this at run time. Instead, I believe my only option is to export 3 different widgets and have them all listed in the widget picker dialog as something like "Weather - current conditions", "Weather - hourly forcast", and "Weather - week long forcast".
I am trying to develop a Android Google Map application, which is basically Gmap with my own marker geo layer. Since android.com is banned in China, I have to search support from Google user groups. I have no idea which groups I should call for help, android group or google map group. Anyway here is my questions:
I am working on Android SDk1.5. I want to reproduce the floating buttons presented in android Google map, which stands for three buttons: ZoomControl (left), FocusChange (middle), and ListControl (right). (Pls check ref1. ) I checked some open source projects, if designer can place these controls in the layout.xml with relative layout, to place them over (on the top of) the mapview. It may solve some problem, however in the SDK1.5' add-on gmap jar, the getZoomControl is discarded. I can only setBuiltInZoomControl(true) to enable the builtin zoomcontrol. By default, the "BuiltIn" Zoom Control is placed at Bottom/Center. (Pls check ref 2.) I have no idea how to relocate the "BuiltIn" Zoom Control to the left as native GMAP does.
So: How to relocate the BuiltIn Zoom Control ? How to add addtional custom control (buttons/overlays) with BuiltInZoomControl ? What functions should be overriden for the detail implementaiton, Such as synhcorization with the visibility? I am appreciated if the answer can be offered with code snippet or references to any internet site.
Ref: 1) http://www.ennovation.org/pix/transit-android-google-maps.png 2) http://www.ennovation.org/pix/device005.png
I've got a query, (I'm using rawQuery())
SELECT * FROM <table>
I'm then storing what it returns using a cursor. From their what I want to do is, start at the first row so.. cursor.moveToFirst() then take each column , column by column and store its particular value in a variable. I then want to move onto the next row and do the same. So I guess my question is How would I get cursor to deal with multiple columns?
I am learning how to program on Android phone. However I am unsure how to make my application work for the different screen sizes and resolutions.
I read the tutorial on the android site and still unsure how to do it.
First I know there are different files so could make a layout for each of the sizes but my problem is most of the screen needs to be dynamically created so there would not be much to put in these files.
So I am not sure how to android to re size dynamic controls based on the screen size.
I have also read it is bad practice to make controls in anything but the xml file as it separates view logic and programming logic. However they never talk about if you need to make these controls dynamically what you should do.
So is there some other way to do it that is considered good practice?
Edit
I get this error when I try to run the switcher application.
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: Error type 2
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: Error: Unable to connect to activity manager; is the system running?
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: usage: am [start|broadcast|instrument|profile]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: am start [-D] INTENT
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: am broadcast INTENT
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: am instrument [-r] [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-w] <COMPONENT>
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: am profile <PROCESS> [start <PROF_FILE>|stop]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: INTENT is described with:
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-c <CATEGORY> [-c <CATEGORY>] ...]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
[2010-04-27 12:06:41 - ViewSwitcherTest] ActivityManager: [-n <COMPONENT>] [-f <FLAGS>] [<URI>]
To your question: It's dynamic because
the buttons in my example grow and
shrink depending on one of the 3
possibles sizes, because they use
scaled pixel (You probably know that
you don't have to deal with screen
sizes itself). So a scaled pixel
compared to a real a pixel has a size
of 0.75px, 1.0px or 1.5px. Android
automatically and dynamically adjusts
it to the actual size. So you don't
have to care about this in your code.
So if I use scaled pixels then I don't have to worry about different screen sizes?
At the moment I don't know an example
except in games where you have to deal
with "real" pixel. But if you want use
it, multiply it with the value of the
current density. This is your "ratio".
I don't have the example with the ball
anymore but I have another which uses
the same technics. You can run it on
different screen sizes and you will
see that the buttons will always fit
into the layout. You could use the
same technics for your intents. In
this example you can scroll with the
"Scrn" buttons from one view to
another of 4 views. (At the moment
they all have a black background so
you don't see that they are different
views). The "Enter" button exits the
test. It's an Eclipse project. You can
download
So if I want to deal with ratio then I use real pixels and not scaled pixels? What advantage does this give me?
will scaled pixels work with changing from portrait to landscape( ie will it fill up the new found space)?
Finally should I make the controls now through code or is there another way? As I said I am getting data from a webservice that must look like this
checkbox label label
It can be one record or 10,000 records I don't know so these have to be appended to something that is like a window panel( the controls in there get a scroll bar).
I have a ListActivity that uses a CursorAdapter to fill the rows in the view. I wrote a database helper class that gives me back results for common queries I make for my app, and it uses an SQLiteOpenHelper implementation I wrote to open the database. I use the open helper to open the database and get a cursor to pass to my CursorAdapter.
Here's a code snippet:
CODE:...................
The problem I'm having, that I didn't have before I implemented the open helper (before I just opened the database directly without a helper), is when I click on an item, which takes me to another activity, and then go back to this activity. When it initializes everything is fine, and my list is populated fine, but when I go back from the activity that follows, the list is empty and in the LogCat I see "Invalid statement in fillWindow()".
It appears from a few post I've seen that the reason is, when I requery the cursor, the database is closed. But I'm not closing it! I'm scratching my head on this one.
What is the deal with sprint navigation.I close the app and 10 minutes later i check my atk and it's open again like a pesky little fly.Is there a way to shut the app down without deleting it and open it when needed?
View 1 Replies View RelatedI'm all new to this android stuff and i was wondering what the big deal of root is? like what can you do with root that you cant do before? Please don't comment if you have something bad to say as you were too once as new as me.
View 3 Replies View RelatedI see that people here have walked out of mobile phone stores with some great bargains. I've been living off my wife's old contract phones for years and I always hated going into stores to look at phone as sales people always tried to sell me stuff I didn't want / need. I've now decided it's time to invest in a Desire with a contract (T-Mobile). Their �10 a month for 100 mins & txt (phone �164) is tempting but I probably prefer 600 mins & unlimited text for �21.35 (after redemption) from buymobilephones.net How's the best way to approach a sales person in a store bearing in mind that I'm a new customer? Are they fairly flexible when it comes to discussing contracts? I just fancy walking in and asking if they can match a certain contract deal on the internet!?
View 2 Replies View RelatedGoing from hero->evo means my mini usb cords are useless. I'm looking around but can't seem to find anyone selling a bundle of maybe 4-5 cords, they seem to all be selling individually along with car/wall chargers (which i won't need)
View 5 Replies View RelatedWhat's the deal with the Flickr integration?I thought I would transition over from Photobucket because it looked like it might make it easier to access and share photos.So I find out that I need a YahooID to sign up for Flickr.Why not something with Google (Picasa)?
View 2 Replies View RelatedI have been looking for a good deal on the Hero. I found the website mobilephonesdirect.co.uk, and they are offering the Hero at �25 for 24 months on Vodafone with 100 mins and 500 txts and unlimited internet. The phone is free and it looks like a great deal. Does anyone have any experience of comments on dealing with these guys?
View 20 Replies View RelatedI have these on my Blackberry and they are as good as any other Invisable Shield type protector at about half the cost. Glad to see they now have them for EVO.INVISIBLE HTC Evo 4G CLEAR Full Body Screen PROTECTOR - eBay (item 370390797766 end time Jul-02-10 16:28:11 PDT)
View 5 Replies View RelatedFirst of all, I'm a very happy Eris user. I've had the phone since January and have just decided to "put up with" the fact the vibration is too weak. But its starting to get rediculous. I miss calls, texts and emails constantly with this phone! And just yesterday, my Boss actually made a comment to me about it (something like "you need to start answering you damn phone!"). I had a BB for 5 years leading up to my getting the Eris in January and rarely missed a call or message.
I have Smart Vibrate loaded and have programmed distinct patterns, but it's not helping. If somebody doesn't have a good idea or remedy for this, I might be forced to go back to BB.
I've read posts like this before and everybody just seems to deal with this, but please tell me somebody has a trick they can share