Java 类android.support.v7.widget.SearchView.OnQueryTextListener 实例源码

项目:CuiMarket    文件:MainActivity.java   
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    // 如果运行的环境 (部署到什么版本的手机 )大于3.0
    if (android.os.Build.VERSION.SDK_INT > 11) {
        SearchView searchView = (SearchView) menu.findItem(
                R.id.action_search).getActionView();
        searchView.setOnQueryTextListener(new OnQueryTextListener() {

            // 当搜索提交的时候
            @Override
            public boolean onQueryTextSubmit(String query) {
                Toast.makeText(getApplicationContext(), query, 0).show();
                return true;
            }
            // 当搜索的文本发生变化
            @Override
            public boolean onQueryTextChange(String newText) {
                return true;
            }
        });// 搜索的监听
    } 
    return true;
}
项目:ListViewVariants    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menuItem_search));
    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(final String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(final String newText) {
            performSearch(newText);
            return true;
        }
    });

    return super.onCreateOptionsMenu(menu);
}
项目:ListViewVariants    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menuItem_search));
    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(final String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(final String newText) {
            performSearch(newText);
            return true;
        }
    });

    return super.onCreateOptionsMenu(menu);
}
项目:netkuu.player    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    SearchView view = (SearchView)
            MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
    if(view != null){
        view.setOnQueryTextListener(new OnQueryTextListener(){
            @Override
            public boolean onQueryTextSubmit(String query) {
                if(query.length() > 0){
                    Intent intent = new Intent(MainActivity.this, SearchActivity.class);
                    intent.putExtra("key", query);
                    startActivity(intent);
                }
                return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                return false;
            }
        });
    }
    return super.onCreateOptionsMenu(menu);
}
项目:Harmony-Music-Player    文件:MusicPicker.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.music_picker, menu);
    SearchView search = (SearchView) MenuItemCompat.getActionView(menu
            .findItem(R.id.action_search));

    search.setOnQueryTextListener(new OnQueryTextListener() {

        @Override
        public boolean onQueryTextChange(String newText) {
            mAdapter.getFilter().filter(newText);
            return true;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            // TODO Auto-generated method stub
            return true;
        }

    });
    search.setOnCloseListener(new OnCloseListener() {

        @Override
        public boolean onClose() {
            mAdapter.getFilter().filter("");
            return false;
        }
    });
    return true;
}
项目:vuze-remote-for-android    文件:TorrentViewActivity.java   
private void setupSearchView(MenuItem searchItem) {
    if (searchItem == null) {
        return;
    }
    mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    if (mSearchView == null) {
        return;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        setupSearchView_Froyo(mSearchView);
    }
    mSearchView.setIconifiedByDefault(true);
    mSearchView.setIconified(searchIsIconified);
    mSearchView.setQueryHint(
            getResources().getString(R.string.search_box_hint));
    mSearchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            AndroidUtils.executeSearch(query, TorrentViewActivity.this, session);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
}
项目:netkuu.player    文件:SearchActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.search, menu);

    SearchView view = (SearchView)
            MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
    view.setOnQueryTextListener(new OnQueryTextListener(){
        @Override
        public boolean onQueryTextSubmit(String query) {
            if(query.length() > 0){
                mVideoAdapter.clear();
                mTotalLength = 0;
                mProgressBar.setVisibility(View.VISIBLE);
                mVideoGrid.setVisibility(View.GONE);
                mPage = 0;
                mVideoAdapter.notifyDataSetChanged();
                search(query);
            }
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    return true;
}