如何使搜索按钮单击的搜索按钮功能?

时间:2019-11-01 01:29:35

标签: android search arraylist full-text-search search-multiple-words

enter image description here当我单击搜索按钮时,它将从recyclerview中搜索特定数据。我尝试了Searchview Listener,它不支持按钮单击搜索。请任何人都可以帮助我完成此操作!谢谢!

2 个答案:

答案 0 :(得分:1)

只需将onclicklistener添加到搜索按钮即可。

private OnClickListener searchListener = new OnClickListener() {
    public void onClick(View v) { // do something when the button is clicked 
    } 
}; 

protected void onCreate(Bundle savedValues) {
    // Capture search button from layout      
    Button button = (Button)findViewById(R.id.search_btn); 
    // Register the onClick listener with the implementation above  
    button.setOnClickListener(searchListener);  
}

看看this

答案 1 :(得分:1)

searchButton.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        // Put your search functionality here
    }
});