Android: onTouch and onTextchanged listener issue
<p>I have a search field(edittext) with cancel and search icons .on top of the contact list , when i type the contact name the name is displaying , and when that name does not exist it give no contact found, </p>

<pre><code>final EditText editTxt = (EditText) findViewById(R.id.txtContName);


    ((Button) findViewById(R.id.btnsearch)).setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    InputMethodManager imm = (InputMethodManager) getSystemService(ProfileActivity.this.INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(editTxt.getWindowToken(), 0);
                    editTxt.setText("");
                    v.setBackgroundResource(R.drawable.search);
                    break;
                case MotionEvent.ACTION_MOVE:
                    break;
                case MotionEvent.ACTION_UP:
                    break;
                }
                return true;
            }
        });             
        editTxt.addTextChangedListener(new TextWatcher() {

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

            public void afterTextChanged(Editable s) {
                final TextView noDataFound = (TextView) findViewById(R.id.norecords);
                inputName = s.toString();
                if(inputName!=null&amp;&amp;!inputName.trim().equals("")){

                Log.d(TAG, "LoadMoreEntries --&gt; Constants.loadEntries : "
                        + Constants.loadEntries);

                    if (Constants.loadEntries != null) {
                        Constants.loadEntries.cancel(true);
                    }

                Constants.loadEntries = new LoadEntries();
                Constants.loadEntries.execute();
            }
                Button closesearch = (Button) findViewById(R.id.closesearch);

                if (inputName != null &amp;&amp; !inputName.trim().equals("")) {
                    closesearch.setVisibility(View.VISIBLE);
                } else {
                    closesearch.setVisibility(View.GONE);
                }

                closesearch.setOnTouchListener(new OnTouchListener() {
                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        if (Constants.loadEntries != null) {
                            Constants.loadEntries.cancel(true);
                            Constants.loadEntries = new LoadEntries();
                            Constants.loadEntries.execute();
                        }else {
                            }
                        return false;
                    }
                });


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

            }
        });
</code></pre>

<p>this my load entries class</p>

<pre><code>public class LoadEntries extends AsyncTask&lt;String, List&lt;Profile&gt;, String&gt; {

        private boolean isThreadCanceled;

        @Override
        protected void onPreExecute() {
            contacts = new ArrayList&lt;Profile&gt;();
            lvContact = (ListView) findViewById(R.id.profilelist);
            lvContact.setTextFilterEnabled(true);
            cAdapter = new ProfileAdapter(_activity, R.layout.profile,
                    contacts, R.layout.profile, profileType, buttonlayout);
            lvContact.setClickable(true);
            lvContact.setAdapter(cAdapter);
            super.onPreExecute();
        }

        protected String doInBackground(String... params) {
            ProfileUtils profileUtils = null;
            boolean isMoreRecord = true;
            List&lt;Profile&gt; profiles = new ArrayList&lt;Profile&gt;();
            boolean isFirstIteration = true;
            try {
                profileUtils = new ProfileUtils(_activity, inputName);
                while(isMoreRecord){
                    profiles = profileUtils.getAllItem();
                    if(profiles == null || profiles.isEmpty()){
                        isMoreRecord = false;
                    }
                    publishProgress(profiles);
                }


            } catch (Exception e) {
                Log.e(TAG, "", e);
            }
            return null;
        }

        protected void onProgressUpdate(List&lt;Profile&gt;... v) {
            super.onProgressUpdate(v);
            contacts.addAll(v[0]);
            Log.d(TAG, "---------------------&gt; Retriving all the messages 01 " + v[0]);
            Log.d(TAG, "---------------------&gt; Retriving all the messages 02 " + contacts);
            cAdapter.notifyDataSetChanged();
        }

        @Override
        protected void onPostExecute(String result) {
            //cAdapter.notifyDataSetChanged();
            if (contacts == null || contacts.isEmpty()) {
                ((ListView) _activity.findViewById(R.id.profilelist))
                        .setVisibility(View.VISIBLE);
                ((TextView) _activity.findViewById(R.id.norecords))
                        .setVisibility(View.VISIBLE);
            }
            new LoadPhoto().execute(contacts);

            super.onPostExecute(result);
        }
</code></pre>

<p>the issue i am facing is after loading the contact name when entered in search ,now when  i touch the cancel button or clear the search field it should load all the contacts but its not happening ,Any help is appreciated.</p>
