AutoCompleteTextView update problem

by Tim » Thu, 05 Nov 2009 01:21:48 GMT

Sponsored Links
 Hi guys

I am completely stuck on this for a few days...any help will be super

I have an AutoCompleteTextView which I want to populate with artist
names based on what the user types. I have a method which makes a call
to the Musicbrainz API which takes a few seconds so I do that in a
separate thread.

The problem is that when I get the list of artist names back from
Musicbrainz, I try and update the ArrayAdapter with a Handler on the
UI thread (which is called from the Musicbrainz thread), but its only
on the next letter entered in the textview that the ArrayAdapter
changes are displayed to the user.

Here is my code:

public void onCreate(Bundle savedInstanceState) {
                AutoCompleteTextView actv = (AutoCompleteTextView) findViewById
                adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());


TextWatcher textWatcher = new TextWatcher() {

                public void onTextChanged(CharSequence s, int start, int 
before, int
count) {
                        Thread t = new Thread() {
                                public void run() {
                                        ArrayList<String> names = 
(ArrayList<String>) getArtistStrings
                                        artistNames = names;

                public void beforeTextChanged(CharSequence s, int start, int 
int after) {

                public void afterTextChanged(Editable s) {

private String getInput() {
                EditText artistInput = (EditText) findViewById
                String artistSearchString = artistInput.getText().toString();
                return artistSearchString;

private void updateTextAdapter(List<String> data) {
                for (String artistName : data) {

        private Handler messageHandler = new Handler() {

                public void handleMessage(Message msg) {



Other Threads

1. Working Around Samsung Double-SD Problem

My thinking was:

if ( android.os.Build.MODEL contains-case-insensitive Vibrant /
Incredible / Galaxy ) {
       if ( dirExists( "/sdcard/sd" ) )
            // use that one
       else if ( dirExists( "/emmc" ) )
            // use that one
else {
   // usual procedure

Does that look right ? I don't have any talkative users for testing




2. UriMatcher "match" not working properly

Somehow my UriMatcher is not working properly and because of that I am
not able to do the CRUD operations on my tables.

I have the following structure of packages and classes:

com.arpit.provider : This has a class MyContentProvider which extends
ContentProvider class
com.arpit.tables :
        DatabaseHelper extends SQLiteOpenHelper
        KeyTable implements BaseColumns
        ParticipantTable implements BaseColumns

Now in MyContentProvider, I have done the following:

public static final String AUTHORITY =
        UriMatcher uriM = new UriMatcher(UriMatcher.NO_MATCH);
        uriM.addUri(AUTHORITY, "key", 0);
        uriM.addUri(AUTHORITY, "participant", 1);
public Cursor query(Uri uri, String[] projection, String selection,
                        String[] selectionArgs, String sortOrder) {
                SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
                        case 0:
                        case 1:

In my KeyTable class, CONTENT_URI = "content://" +
MyContentProvider.AUTHORITY + "/key";
In my ParticipantTable class CONTENT_URI = "content://" +
MyContentProvider.AUTHORITY + "/participant";

In my AndroidManifest.xml file I have registered the provider as:

<provider android:name="com.arpit.providers.MyContentProvider"

Now I make the query call with the following statement in my

Cursor cursor = getContentResolver().query(KeyTable.CONTENT_URI, new
String[] { KeyTable.col1 }, "_id='1'", null,  null);

My problem is when the Query Method is called and the Switch block is
executed the uriM.match returns always -1 (irrespective of whether it
is KeyTable.CONTENT_URI or ParticipantTable.CONTENT_URI).

Could you let me know what wrong am I doing because of which it is not

they call managedQuery instead of getContentReslover().query(...). I
tried firing managedQuery(...) in my HomeActivity class, but that also
result in uriM.match(uri) to return -1.

It will be great if you could help me out.

Thanks & Regards,


3. Adding checkboxes to a LinearLayout

4. Twitter4j 2.1.4 HttpClietImpl calls wrong Scheme Constructor

5. Versioning and common code-bases with Eclipse

6. How to prevent a service from being restarted by the system...

7. Camera rotation (output and capture)