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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:29:07+00:00 2026-05-15T06:29:07+00:00

The layout is basic: an EditText at the top followed by a ListView. EditText

  • 0

The layout is basic: an EditText at the top followed by a ListView. EditText has a TextWatcher.onTextChanged implemented so that ArrayAdapter.getFilter.filter is called with the entered text. ArrayAdapter’s data is refreshed asynchronously on resume (see code snippet below). Easy enough, works just fine too… right up until the screen orientation is changed. Why would filtering suddenly break when the phone is turned sideways?

public class SometActivity extends ListActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        ...
        listAdapter = new ArrayAdapter<MemoryStatistic>(this, R.layout.list_item);
        setListAdapter(listAdapter);
        searchText = (EditText)findViewById(R.id.searchText);
        searchText.addTextChangedListener(new TextWatcher()
        {
            @Override
            public void onTextChanged(CharSequence text, int start, int before, int count)
            {
                listAdapter.getFilter().filter(text);
            }
            ...
        }
        ...
    }

    @Override
    protected void onResume()
    {
        asyncRefreshListAdapter();//refresh the data asynchronously when activity is resumed
    }
}
  • 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-05-15T06:29:08+00:00Added an answer on May 15, 2026 at 6:29 am

    I thought I’d make this self-reply post in case other programmers who are new to Android development (like I am) become stumped by this. So, according to android reference onResume will only be called if Activity is

    1) created

    2) restarted

    3) resumed (brought to foreground after resume)

    Ok, so what does screen orientation have to do with this?
    Well, most devs who read documentation skim through it on the account of the fact that there’s a lot to read and they just want to get to implementing something cool. I was no different. If only I had read further, I would’ve avoided a lot of headache later on:

    Unless you specify otherwise, a configuration change (such as a change in screen orientation, language, input devices, etc) will cause your current activity to be destroyed

    And now it’s obvious why filter wouldn’t work correctly. The problem was that (once the activity was destroyed on screen orientation change) listAdapter wasn’t fully or at all populated (due to the asynchronous nature of the refresh) before filtering would commence.

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

Sidebar

Related Questions

I have a stored proc with the basic layout below that returns a sys_refcursor
I am implementing listview with 2 textviews , and for reference used Basic Layout
I am looking into a basic DOM layout that lets me put a couple
I have a basic website nav layout that looks like this: <li class=folder parent_folder>
Just a basic question: If I have several dozen EditText fields that are part
I have the following very basic layout for each row of a ListView .
I have a basic layout that is one Div container wrapper and three columns
I have a web-crawler where the basic layout is a manager that runs agents
I have a basic layout page template: --- layout: default --- <header class="sidebar"> {{
I have a basic layout where different components can be selected using a tree

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.