I am not able to avoid creating a new adapter after every search.

On Thu, Feb 9, 2012 at 5:12 PM, vani reddy <vani.reddy.bl...@gmail.com>wrote:

>    What i did is the below.Among the points which you mentioned i used
> timer concept
> and  Optimising search using. *start*, *before*, and *count* .
>
>
>
>  public void onTextChanged(CharSequence s, int start, int before,
>                     int count) {
>
>                 System.out.println("S " + s);
>                 System.out.println("start  " + start);
>                 System.out.println("before " + before);
>                 System.out.println("count  " + count);
>
>
>                 if (count >= 0 && (start >= 0)) {
>
>                     if (Thread.currentThread().isAlive())
>                         ;
>                     {
>                         Thread.currentThread().interrupt();
>                     }
>
>                     t = new Thread(null, loadSearchItems);
>                     t.start();
>                 }
>
>               }
>
>>
>>
>
>
> private Runnable loadSearchItems = new Runnable() {
>         @Override
>         public void run() {
>
>             try {
>                 synchronized (t) {
>                     t.wait(1000);
>                 }
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>             System.out.println("AFTER 2 SECONDS *****************");
>
>             List<Show> _sortShow = new ArrayList<Show>();
>             String searchStr = search_feild.getText().toString().trim()
>
>                     .toLowerCase();
>             _sortShow.clear();
>             for (int i = 0; i < m_ChannelList.getData().size(); i++) {
>
>                 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);
>
>             }
>             runOnUiThread(updateSearchAdapter);
>
>         }
>     };
>
> private Runnable updateSearchAdapter = new Runnable() {
>         @Override
>         public void run() {
>
>
>             adapter = new LazyAdapterChannelList(ChannelGuideActivity.this,
>                     sorted_ChannelList);
>             setListAdapter(adapter);
>
>         }
>     };
>
>


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

Reply via email to