0. Stop creating new adapter and adding it to your ListView every time
user types anything. Consult ListAdapter API - there are methods to
accommodate your needs.
1. Don't scan all items every time user changes the input. Add timer
to perform the search/filter and delay the search by say 0.9sec
resetting the timer in onTextChanged.
2. Optimise your search. *start*, *before*, and *count* are there for a reason.
3. If you are ambitious, use better data structure behind the adapter
to speed up your search or place your data in DB and use
CursorAdapter.



On 8 February 2012 12:27, vani reddy <vani.reddy.bl...@gmail.com> wrote:
>
> Hello,
>
> I  have a listview in which i am loading data of size 400. for  the edittext
> i am giving
>
>
>     search_feild.addTextChangedListener(new TextWatcher() {
>             List<Show> _sortShow = new ArrayList<Show>();
>
>             public void afterTextChanged(Editable s) {
>             }
>
>             public void beforeTextChanged(CharSequence s, int start, int
> count,
>                     int after) {
>             }
>     public void onTextChanged(CharSequence s, int start, int before,
>                     int count) {
>
>                   searchStr = search_feild.getText().toString().trim()
>                  .toLowerCase();
>                _sortShow.clear();
>                   for (int i = 0; i < m_ChannelList.getData().size(); i++) {
>
>                   if (textlength <= m_ChannelList.getData().get(i)
>                  .getListing_name().length() || textlength <=
>                   m_ChannelList.getData().get(i) .getCh_name().length()) {
>
>                   Show show = m_ChannelList.getData().get(i);
>
>                    if ((((String)
>                  show.getListing_name().toLowerCase()) .contains(searchStr))
>                   || (((String) show.getCh_name().toLowerCase())
>                   .contains(searchStr))
>
>                  )
>                              {
>
>                       _sortShow.add(show);
>                          }
>                sorted_ChannelList.setData(_sortShow);
>
>
>
>
>                  adapter = new
> LazyAdapterChannelList(ChannelGuideActivity.this,
>                  sorted_ChannelList); setListAdapter(adapter);
>
>             }
>         });
>
> it is blocking the UI,How to resolve it
> --
> Regards,
> Vani Reddy
>
> --
> 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+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
Daniel Drozdzewski

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to