Why does setTextFilterEnabled(true) not work?

by guishenl...@gmail.com » Thu, 30 Jul 2009 17:44:02 GMT

Sponsored Links
 Hi all,
    I want to design a ListView with auto filter fuction, that is,
when the user press a key all the items who matches this key will be
filtered and form a new list.
I selected the method setTextFilterEnabled(true) to implement my
function, but it didn't work in fact.
Could anyone tell me where my mistacke exists?
Thank you in advance!

Here is my code:

package com.example.android.apis.view;

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;

 * A list view example where the
 * data for the list comes from an array of strings.
public class List1 extends ListActivity {

    public void onCreate(Bundle savedInstanceState) {

        // Use an existing ListAdapter that will map an array
        // of strings to TextViews
        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, mStrings));

    private String[] mStrings = {
            "Action", "Adventure", "Animation", "Children", "Comedy",
"Documentary", "Drama",
        "Foreign", "History", "Independent", "Romance", "Sci-Fi",
"Television", "Thriller"



Other Threads

1. Making SearchManager behave like the old googlenav.Search

So I have been looking into this for a couple of days, and I am pretty
sure the intent of the android API team is to make SearchManager a
platform level tool for searching application level content, like a
application database, which is very cool, and I will probably use, but
not what I want at this moment.

I want to be able search a map just like the Google search apis for

// We'll wait to the end to actually initialize the map
      // So let's build the search control
      searchControl = new google.search.SearchControl();

      // Initialize a LocalSearch instance
      searcher = new google.search.LocalSearch(); // create the object

      searcher.setCenterPoint(map); // bind the searcher to the map

      // Create a SearcherOptions object to ensure we can see all
      var options = new google.search.SearcherOptions(); // create the

      // Add the searcher to the SearchControl
      searchControl.addSearcher(searcher , options);

     // And second, we need is a search complete callback!
      searchControl.setSearchCompleteCallback(searcher , function() {
        var results = searcher.results; // Grab the results array
        // We loop through to get the points
        for (var i = 0; i < results.length; i++) {
          var result = results[i]; // Get the specific result
          var markerLatLng = new google.maps.LatLng(parseFloat
          var marker = new google.maps.Marker(markerLatLng); // Create
the marker

          // Bind information for the infoWindow aka the map marker
          result.marker = marker; // bind the marker to the result
          map.addOverlay(marker); // add the marker to the map

This *was* in previous versions of the API (1.0?) I have seen very old
code like:

// W00t! Search for Pizza.
            // Create a MapPoint from the map's coordinates
            MapPoint mapPoint = new MapPoint(mMapView.getMapCenter
            // Create a dummy Map for use in Search
            Map map = new Map(getDispatcher(), null, 0, 0, 0,
                    Zoom.getZoom(mMapView.getZoomLevel()), 0);
            // Search for Pizza near the specified coordinates
            Search search = new Search("Pizza", map, 0);
            // add the request the dispatcher
            // Wait for the search to complete, Should do this
            // in another thread ideally, this is just for
illustration here.
            while (!search.isComplete()) {
                Log.i(LOG_TAG, ".");

            // Print the details.
            Log.i(LOG_TAG, "Done - " + search.numPlacemarks());
            MapPoint point = null;
            for (int i = 0; i < search.numPlacemarks(); i++) {
                Placemark placemark = search.getPlacemark(i);
                point = placemark.getLocation();
                Log.i(LOG_TAG, " - i : " + Integer.toString(i));
                Log.i(LOG_TAG, "- Bubble : " +
                Log.i(LOG_TAG, "- Detail : " +
                Log.i(LOG_TAG, "- Title : " + placemark.getTitle());
                Log.i(LOG_TAG, "- Location : " + placemark.getLocation
                Log.i(LOG_TAG, "- routable : " +

            // Animate to the last location.
            if (point != null) {
                MapController mc = mMapView.getController();
                Point point1 = new Point(point.getLatitude(),
                Log.i("animateTo", point1.toString());

I have been thinking it could be possible by geocoding an address
using the location manager:

//first find the location using geocoding
                Geocoder geocoder =
                        new Geocoder(getApplicationContext(), 
                try {
                                List<Address> addrs =
geocoder.getFromLocation(mMyLocationLat, mMyLocationLon, 1);

                        } catch (IOException e) {
                                Log.e(TAG, "geocoding failed");

and then pre populating the search with something like "pizza @94611",
but right now when I do search the results go to a browser, I really
want to be able to parse the results myself using an api.

Does anyone know of an example like this or can give me some advice,
the API docs on SearchManager are a little difficult because I think
the intentions are mixed. Is this the right approach? Is it even



2. New device best practices (donut vs. eclair, etc)

  I'm trying to port android to a custom embedded (x86-based) system.   
What would be the best practice at this point - going with the partial  
eclair (the 'missing' stuff appears to be manufacturer related, which  
is not applicable to our device?), or the donut release?  For those of  
us not running on HTC hardware and phones from major vendors (we have  
GSM connectivity, but are not a 'phone'), is there a guide or document  
for things to look out for and stuff to do?  Of the current-seeming or  
latest documentation, it seems as if everything is focused on one or  
two phones as hardware platforms...



unsubscribe: android-porting+unsubscr...@googlegroups.com

3. Adjusting Dialog Size Question (ie: ColorPal)

4. A request for people creating custom Android systems

5. OpenGL ES works fine on Emulator but on HTC Hero 1.5 it does not render vertices

6. JSONObject text must begin with '{' at character 1

7. Archos/Android development