I tested this sample code and it seems to work. Maybe it will help you solve your issue:
public class TestActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EditText inputSearch = new EditText(this);
inputSearch.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
// When user changed the Text
((SimpleAdapter)getListAdapter()).getFilter().filter(cs);
}
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});
getListView().addHeaderView(inputSearch);
ArrayList<HashMap<String, String>> songsListData = new ArrayList<HashMap<String, String>>();
{
HashMap<String, String> song = new HashMap<String, String>();
song.put("songTitle", "We are made of stars");
song.put("artist", "Moby");
songsListData.add(song);
}
{
HashMap<String, String> song = new HashMap<String, String>();
song.put("songTitle", "Californication");
song.put("artist", "Red hot chili peppers");
songsListData.add(song);
}
// Adding menuItems to ListView
String[] from = { "songTitle", "artist" };
int[] to = { R.id.songTitle, R.id.songArtist };
SimpleAdapter adapter = new SimpleAdapter(this, songsListData, R.layout.playlist_item, from, to);
setListAdapter(adapter);
}
}
With the following playlist_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/songTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/songArtist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp" />
<TextView
android:id="@+id/duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp" />
</LinearLayout>