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
appreciated!

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
(R.id.artist_search_text_edit);
                actv.addTextChangedListener(textWatcher);
                adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, new ArrayList<String>());
                actv.setAdapter(adapter);

        }

TextWatcher textWatcher = new TextWatcher() {

                @Override
                public void onTextChanged(CharSequence s, int start, int 
before, int
count) {
                        Thread t = new Thread() {
                                public void run() {
                                        ArrayList<String> names = 
(ArrayList<String>) getArtistStrings
(getInput());
                                        artistNames = names;
                                        messageHandler.sendEmptyMessage(0);
                                }
                        };
                        t.start();
                }

                @Override
                public void beforeTextChanged(CharSequence s, int start, int 
count,
int after) {
                }

                @Override
                public void afterTextChanged(Editable s) {
                }
        };

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


private void updateTextAdapter(List<String> data) {
                adapter.clear();
                for (String artistName : data) {
                        adapter.add(artistName);
                }
                adapter.notifyDataSetChanged();
        }

        private Handler messageHandler = new Handler() {

                @Override
                public void handleMessage(Message msg) {
                        updateTextAdapter(artistNames);
                }

        };

--



Other Threads

1. Media gathering and launching HTC Legend, HD Mini dan HTC Smart

Megang2 aja sih boleh, asal jangan dibawa pulang yah mas... Wekwekwek

Kerennnn dong... Ada dagunya mas, amoled, 384RAM, unibody aluminium 
full...apalagi yah?

*elus2 dagu nareen
@jakontil
www.jeruknipis.com/forum
ris...@naekgenteng.com

-----Original Message-----
From: "masdri.droid" <masdrie.mi...@gmail.com>
Date: Wed, 5 May 2010 00:39:22 
To: Indonesian Android Community [id-android]<id-android@googlegroups.com>
Subject: [id-android] Re: Media gathering and launching HTC Legend, HD Mini 
        dan HTC Smart

Kok gw jadi pengen megang legend yak?
Seberapa kuatkah itu ratjoennya ntil?........







> Join:

2. Bluetooth error

Hi,

# E/BluetoothDevice(  784): BT_DBG: enable Called
E/BluetoothDeviceService(  656): enableNative will be called now...
E/BluetoothDeviceService.cpp(  656): BT_DBG bt_enable will be called now...
E/BluetoothDeviceService.cpp(  656): BT_DBG bt_enable will be called now...
I/bluedroid(  656): Starting hcid deamon
E/BluetoothDeviceService(  656): BT_DBG inside
BluetoothDeviceService->enable
I/bluedroid(  656): Starting hciattach daemon
I/bluetooth_ScoSocket.cpp(  695): Listening SCO socket...
E/bluetooth_common.cpp(  656): dbus_func_args_timeout_valist: D-Bus error in
GetName: org.freedesktop.DBus.Error.NoMemory
(Not enough memory)
E/bluetooth_common.cpp(  656): dbus_func_args_timeout_valist: D-Bus error in
ListBondings: org.freedesktop.DBus.Error.Unkn
ownMethod (Method "ListBondings" with signature "" on interface
"org.bluez.Adapter" doesn't exist
E/bluetooth_common.cpp(  656): )
E/BluetoothDeviceService.cpp(  656): startDiscoveryNative: D-Bus error:
org.freedesktop.DBus.Error.UnknownMethod (Method "
DiscoverDevices" with signature "" on interface "org.bluez.Adapter" doesn't
exist


What does this error mean ?
Why isn't org.bluez.Adapter recognised ??

Please suggest.

Thanks & Regards,
Pavan Savoy.











--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [EMAIL PROTECTED]
website: 

3. Parcelable datatype in AIDL file

4. Adding an HTML content to a webview without space

5. When "com.remoba.eas.activity:remote" will run?

6. Problem with StateListDrawables not found in 1.5 but there from 1.6 onwards

7. Creating tabs for calling activities