简体   繁体   English

实现搜索栏 android

[英]implement search bar android

I am trying to implement the uisearch bar common to the ios in android.我正在尝试在 android 中实现 ios 通用的 uisearch 栏。 What is the best way of approaching this?解决这个问题的最佳方法是什么? I have searched to no avail.我已经搜索无济于事。 Would anyone give a helping hand?有人会伸出援助之手吗? Much thanks.非常感谢。

This is a good solution:这是一个很好的解决方案:

 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) {
            lvAdapter.getFilter().filter(s);
            lvAdapter.notifyDataSetChanged();
        }
    };
    EditText filterText = (EditText) findViewById(R.id.EditText01);
    filterText.addTextChangedListener(filterTextWatcher);

At the moment, the best case could be to implement the google search features available in android:)目前,最好的情况是实现 android 中可用的 google 搜索功能:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM