Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9252219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:53:24+00:00 2026-06-18T10:53:24+00:00

I have a edit text and a listview with all contacts .when i search

  • 0

I have a edit text and a listview with all contacts .when i search for the name and it displayes the result, As i type in the name it shows the result like AutoComplete, below is my code

final EditText editTxt = (EditText) findViewById(R.id.txtContName);

    editTxt.addTextChangedListener(new TextWatcher() {

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

        public void afterTextChanged(Editable s) {
            inputName = s.toString();
            if(inputName!=null&&!inputName.trim().equals("")){

                ((Button) findViewById(R.id.btnsearch)).setBackgroundResource(R.drawable.search);

            Log.d(TAG, "LoadMoreEntries --> Constants.loadEntries : "
                    + Constants.loadEntries);
            try {
                if (Constants.loadEntries != null) {
                    Constants.loadEntries.cancel(true);
                }
            } catch (Exception e) {
                Log.e(TAG, "Loading Data-------------------------------", e);
            }
            Constants.loadEntries = new LoadEntries();
            Constants.loadEntries.execute();
        }
        }

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

        }
    });

i am facing issue when i am trying to clear the edittext ,All the results should be displayed when the edit text is clear but it is not happening. Any help is appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:53:26+00:00Added an answer on June 18, 2026 at 10:53 am

    So I change the code for better formatting. This should solve you’re problem. I don’t know what
    Constants.loadEntries = new LoadEntries();
    and
    Constants.loadEntries.execute();

    do, but maybe there can be something wrong too. But try it like the code below:

        final EditText editTxt = (EditText) findViewById(R.id.txtContName);
    
        editTxt.addTextChangedListener(new TextWatcher()
        {
    
            public void beforeTextChanged(CharSequence s, int start, int count,
                                          int after)
            {
            }
    
            public void afterTextChanged(Editable s)
            {
                inputName = s.toString();
                if (inputName != null && !inputName.trim().equals(""))
                {
    
                    ((Button) findViewById(R.id.btnsearch)).setBackgroundResource(R.drawable.search);
    
                    Log.d(TAG, "LoadMoreEntries --> Constants.loadEntries : "
                            + Constants.loadEntries);
                    try
                    {
                        if (Constants.loadEntries != null)
                        {
                            Constants.loadEntries.cancel(true);
                        }
                    } catch (Exception e)
                    {
                        Log.e(TAG, "Loading Data-------------------------------", e);
                    }
                    Constants.loadEntries = new LoadEntries();
                    Constants.loadEntries.execute();
                }
                //Here do the else and call the LoadEntries
                else
                {
                    Constants.loadEntries = new LoadEntries();
                    Constants.loadEntries.execute();
                }
            }
    
            public void onTextChanged(CharSequence s, int start, int before,
                                      int count)
            {
    
            }
        });
    

    Better code formatting will definitely help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an edit text which functions as a search box in my application.
In my application, in an activity i have 4 edit Text fields and a
I have an application that allows the user to edit multiple text fields and
i have to make a notepad where i write,edit,clear the text. this notepad need
I have a text file that I want to edit by rewriting it to
Hallo all, I have a ListView, which contains an EditText in each of it's
Hallo all, I have a ListView which contains a Button in each line. The
I have a listview with a checkbox, an image and a text field. Now
I have a listview with different layouts for all the listitems. My first listitem
I have a screen with an EditText and a ListView. As you type into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.