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 9111401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:29:46+00:00 2026-06-17T03:29:46+00:00

In my activity I have a ListView with a customadapter. The first item in

  • 0

In my activity I have a ListView with a customadapter. The first item in that ListView is an EditText.
This EditText has a TextWatcher that causes the list to be filtered.

search.addTextChangedListener(textWatcher);
search.setOnFocusChangeListener(focusListener);

TextWatcher textWatcher = new TextWatcher() {

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if(getContext() instanceof ListActivity) {
            ListAdapter adapter = ((ListActivity)getContext()).getListAdapter();
            if(adapter instanceof TCListObjectAdapter) {
                requestfocus = true;
                ((TCListObjectAdapter) adapter).getFilter().filter(s);
            }
        }
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
    @Override
    public void afterTextChanged(Editable s) { }
};

OnFocusChangeListener focusListener = new OnFocusChangeListener() {
    public void onFocusChange(View v, boolean hasFocus) {
        if (!hasFocus && requestfocus){
            search.post(new Runnable() {

                @Override
                public void run() {
                    search.requestFocus();
                    requestfocus = false;
                }
            });
        }
    }
};

The filtering of the list happens as expected. But sometimes after the text is changed, the first row of the listview becomes focussed: in this case the cell of the searchbox but not the EditText. If the user wants to continue filtering the list, he first has to select the EditText again.

I don’t want to turn off the option to focus cells in the listview for the visial effect.

Any ways to avoid losing focus of the EditText while filtering?

  • 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-17T03:29:47+00:00Added an answer on June 17, 2026 at 3:29 am
    getListView().addHeaderView(new EditText(this));
    

    This fullfills these needs.

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

Sidebar

Related Questions

I have a list view in this activity First, i will display list view
I have created a listview that sits inside a larger activity (the list view
I have a ListView in my activity. Each row includes three TextViews in this
I have an activity which consists of a ListView . The problem is that
I have an Activity in Android, with two elements: EditText ListView When my Activity
I have one SubjectTabActivity and i need to show listview on this activity. But
I have a ListView that uses Linkify to create a link to another activity
I have a problem with custom listview item click. In my activity I have
I have an EditText component that searches a list using a custom adapter. It
I have an activity which have ListView. When I want to access this ListView

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.