Listview的搜索过滤器

时间:2015-05-10 15:18:22

标签: java android listview arraylist

我正在创建一个求职应用程序,该应用程序将作业信息显示为列表视图,其中数据来自WAMP服务器数据库。我遇到了一个问题:无法解决方法' getStringArrayList' ,当我为这个Listview制作搜索过滤器时。请参阅SearchFilter.java的第11行。有人可以帮忙吗?非常感谢你!

SearchFilter.java

public class SearchFilter extends ListActivity {
private EditText filterText = null;
ArrayAdapter<String> adapter = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

filterText = (EditText) findViewById(R.id.search_box);
filterText.addTextChangedListener(filterTextWatcher);

setListAdapter(new ArrayAdapter<String>(this,
        android.R.layout.simple_list_item_1,
        getStringArrayList()));                   ***<<<<< this line !***
}

private TextWatcher filterTextWatcher = 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) {
    adapter.getFilter().filter(s);
}

};

@Override
protected void onDestroy() {
super.onDestroy();
filterText.removeTextChangedListener(filterTextWatcher);
}

}

0 个答案:

没有答案