Wednesday, June 9, 2010

Re: [android-developers] Re: Need help on List Adapter

I would like to display the list dynamically filtered by the text input entered by the user on the textbox. the Problem that I am facing NotifyDataSetChanged() is refreshing the list based on the text input

On Tue, Jun 8, 2010 at 12:26 AM, Tommy <droidap@gmail.com> wrote:

Are you getting any errors? what do you mean by NofifyDataSetChanged is not working as expected?

 

From: android-developers@googlegroups.com [mailto:android-developers@googlegroups.com] On Behalf Of Ramesh Sangili
Sent: Friday, June 04, 2010 10:58 PM
To: android-developers@googlegroups.com
Subject: [android-developers] Re: Need help on List Adapter

 

Any help is greatly appreciated!!!

 

Please guys share your thougths

On Sun, May 30, 2010 at 8:01 AM, Ramesh Sangili <ramesh.sangili@gmail.com> wrote:

Guys,

 

  I am extending BaseAdapter and trying to populate the List Screen on my Activity Screen. NotifyDataSetChanged is not working as expected. Please find the below snippet of code. Please do let me know your thoughts.

 

 

 

 

 

 

 

           

            public void onCreate(Bundle savedInstanceState) {

 

                        super.onCreate(savedInstanceState);

                       

                        initialize();

                        context = this;

                        config = Config.getInstance();

                        searchText =  new EditText(this);

                       

                        handler = new Handler() {

                                   

                                    @Override

                                    public void handleMessage(Message msg) {

                                                msgQueueAdapter.notifyDataSetChanged();

                                                context.msgQueueAdapter.notifyDataSetChanged();

                                                msgQueueAdapter.notifyDataSetInvalidated();

                                    }         

                        };

                       

                        searchText.addTextChangedListener( new TextWatcher() {

                                   

                                    @Override

                                    public void onTextChanged(CharSequence s, int start, int before, int count) {

                                                // TODO Auto-generated method stub

                                                Log.d("on text", "String: " + s);

                                                loadData(s.toString());

                                                msgQueueAdapter = new ListAdapter(context, msgQueueList);

                                                Message msg = handler.obtainMessage();

                                                handler.sendMessage(msg);

                                                searchText.bringToFront();

                                               

                                                runOnUiThread(new Runnable()  {

                                                           

                                                            @Override

                                                            public void run() {

                                                                        msgQueueAdapter.notifyDataSetChanged();

                                                                        searchText.setCursorVisible(true);

                                                                        searchText.setClickable(true);

                                                            }

                                                });

                                    }

                                   

                                    @Override

                                    public void beforeTextChanged(CharSequence s, int start, int count,

                                                            int after) {

                                   

                                               

                                    }

                                   

                                    @Override

                                    public void afterTextChanged(Editable s) {

                                                // TODO Auto-generated method stub

                                               

                                    }

                        });

                       

                        msgQueueAdapter = new ListAdapter(this, msgQueueList);

                        Log.d("list", "List Display - 1" + msgQueueAdapter);

                       

                        msgQueueListView = this.getListView();

                        msgQueueListView.addHeaderView(searchText);

                       

                        setListAdapter(msgQueueAdapter);

                        msgQueueAdapter.notifyDataSetChanged();

                        this.msgQueueAdapter.notifyDataSetInvalidated();

            }

 

 

--

You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment