Android: fastScrollEnabled no funciona al principio

OK, estoy trabajando en una aplicación que tiene una página con una vista de lista y un cuadro de edición de texto en la parte superior. A medida que escribe cosas en el cuadro de texto de edición, filtrará los elementos que se muestran en la vista de lista. El problema que tengo es con el icono de desplazamiento rápido que aparece en el lado del control deslizante.
Cuando la página se carga por primera vez, NO IMPORTA, lo que hago, el icono del control deslizante de desplazamiento rápido no aparecerá en la pantalla. Luego hago clic en el cuadro de texto de edición, escribo un carácter y luego lo borro y ahora aparece el icono del control deslizante de desplazamiento rápido.

En primer lugar no carga el icono de desplazamiento rápido.

Aparece el cuadro de texto y luego borra el texto y aparece el icono de desplazamiento rápido.


Tengo el conjunto de android: fastScrollEnabled = "true" en mi vista de lista. Además, lo puse manualmente en el código haciendo lv1.setFastScrollEnabled (true);

No importa si cambio, sigo teniendo el mismo comportamiento, a menos que lo elimine por completo del código y xml y luego deje de funcionar en la segunda página. He intentado limpiar mi proyecto y todavía no sirve. Me estoy inclinando hacia que sea un error en Android o me estoy perdiendo algo extremadamente simple.

Aquí está mi código.

<code>public class SearchByFood extends ParentClass
{
private ListView lv1;
private EditText ed;
int textlength = 0;
private ArrayList<String> arr_sort = new ArrayList<String>();
private ArrayList<String> foods = new ArrayList<String>();
private LayoutInflater mInflater;
private ArrayList<Food> foodList;

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_by_food);
    setTextTitle("Search by Food");

    lv1 = (ListView) findViewById(R.id.ListView01);
    ed = (EditText) findViewById(R.id.EditText01);
    mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    DataLayerFunctions d = new DataLayerFunctions(getApplicationContext());

    foodList = d.selectFoodsWithSubstitutes();
    for (Food f : foodList)
    {
        // this is to build a ArrayList<String> to pass to the setAdapter
        Log.d("SearchByFood", "FoodName: " + f.getFood_Name());
        foods.add(f.getFood_Name());
    }

    ArrayAdapter<String> firstAdapter = new ArrayAdapter<String>(SearchByFood.this, R.layout.search_food_listview, foods);
    lv1.setAdapter(firstAdapter);
    lv1.setFastScrollEnabled(true);

    ed.addTextChangedListener(new TextWatcher()
    {
        public void afterTextChanged(Editable s)
        {
        }

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

        public void onTextChanged(CharSequence s, int start, int before, int count)
        {
            textlength = ed.getText().length();
            arr_sort.clear();
            for (String f : foods)
            {
                if (textlength <= f.length())
                {
                    if (f.toString().toLowerCase().contains((CharSequence) ed.getText().toString().toLowerCase()))
                    {
                        Log.d("STRING", "STRING: " + f.toString() + " contains " + ed.getText());

                        if (ed.getText().length() > 0)
                        {
                            String newString = boldMyString(f, ed.getText().toString());
                            arr_sort.add(newString);
                        }
                        else
                        {
                            arr_sort.add(f);
                        }

                    }
                }
            }

            // if empty add a no foods found
            if (arr_sort.isEmpty())
            {
                arr_sort.add("No Foods Found");
            }

            // Load array
            // lv1.setAdapter(new
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(SearchByFood.this, R.layout.search_food_listview, arr_sort)
            {
                @Override
                public View getView(int position, View convertView, ViewGroup parent)
                {
                    View row;

                    if (null == convertView)
                    {
                        row = mInflater.inflate(R.layout.search_food_listview, null);
                    }
                    else
                    {
                        row = convertView;
                    }

                    TextView tv = (TextView) row.findViewById(android.R.id.text1);
                    tv.setText(Html.fromHtml(getItem(position)));
                    // tv.setText(getItem(position));

                    return row;
                }

            };
            lv1.setAdapter(adapter);
        }

        private String boldMyString(String foodName, String guess)
        {
            int gLength = guess.length();
            ArrayList<Integer> results = new ArrayList<Integer>();

            for (int i = foodName.toLowerCase().indexOf(guess.toLowerCase()); i >= 0; i = foodName.toLowerCase()
                    .indexOf(guess.toLowerCase(), i + 1))
            {
                System.out.println("TEST:" + i);
                results.add(i);
            }

            // Count value is for words that have 2 or more values of guess
            // in them.
            int count = 0;
            for (int i : results)
            {
                StringBuffer s1 = new StringBuffer(foodName);
                s1.insert(i + count, "<b>");
                count = count + 3;

                s1.insert(i + count + gLength, "</b>");
                count = count + 4;

                foodName = s1.toString();
                System.out.println("FOOD NAME:" + i + ":" + foodName);

            }
            return foodName;
        }
    });

    // This is what actually does stuff when you click on a listview item.
    lv1.setOnItemClickListener(new OnItemClickListener()
    {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id)
        {

            // Strip out the bold tags
            String clicked = (String) lv1.getItemAtPosition(position);
            clicked = clicked.replaceAll("<b>", "");
            System.out.println("Clicked" + clicked);
            clicked = clicked.replaceAll("</b>", "");

            // Find the Food ID match and pass the food id to the
            // fooddisplay page
            for (Food f : foodList)
            {
                if (null != clicked && clicked.equals(f.getFood_Name()))
                {
                    Intent intent = new Intent(SearchByFood.this, SubstituteDisplay.class);
                    intent.putExtra("FoodID", f.getFood_ID());
                    startActivity(intent);

                }
            }
        }

    });

}

@Override
public void onBackPressed()
{
    final Intent intent = new Intent(this, MasterTemplateActivity.class);

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    this.startActivity(intent);
    return;
}
}
</code>


Nuevamente, cualquier ayuda sobre por qué mi ícono de desplazamiento rápido no aparece al principio sería muy apreciada. Es una cosa pequeña pero realmente me molesta.

Respuestas a la pregunta(2)

Su respuesta a la pregunta