小编And*_*ise的帖子

如何在android中处理Search View的后退按钮

我已经开发了一个在操作栏中有搜索视图的应用程序,当我完全搜索其过滤器时我遇到问题但是当我按下按钮时它仍然显示过滤器数据所以我的问题是什么是Action Bar Search的后退按钮事件视图.?

在此输入图像描述

我的搜索视图代码是

SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(Menus.SEARCH));
    searchView.setQueryHint(this.getString(R.string.search));
    editSearch = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    editSearch.setHintTextColor(getResources().getColor(R.color.white));
    searchView.setOnQueryTextListener(OnQuerySearchView);


 private OnQueryTextListener OnQuerySearchView = new OnQueryTextListener() {

    @Override
    public boolean onQueryTextSubmit(String newText) {
        if (TextUtils.isEmpty(newText)) {
            listAllContact.clearTextFilter();
        } else {
            listAllContact.setFilterText(newText.toString());
        }
        return true;
    }

    @Override
    public boolean onQueryTextChange(String newText) {
        String text = editSearch.getText().toString()
                .toLowerCase(Locale.getDefault());
        adapter.filter(text);
        return true;
    }

};
Run Code Online (Sandbox Code Playgroud)

适配器中的过滤方法

public void filter(String charText) {
    charText = charText.toLowerCase(Locale.getDefault());
    propertyList.clear();

    if (charText.length() == 0) {
       propertyList.addAll(arrayList);
    notifyDataSetChanged();

    } else {
        for (ContactProperty p …
Run Code Online (Sandbox Code Playgroud)

android searchview android-search

11
推荐指数
3
解决办法
2万
查看次数

使用"拉到刷新"滚动列表视图时发出问题

我开发了一个具有一个列表视图的应用程序,我使用Pull来刷新刷新列表数据,同时下拉,所以我在我的代码中完美实现但是当我向上滚动列表向下滚动时我得到一个问题但是当我向下滚动它不滚动完成,因为它考虑拉动刷新和刷新数据但我想在显示列表索引0然后它工作拉动刷新

所以请帮帮我

我的代码是

 listNotification = (ListView) rootView.findViewById(R.id.listNotification);
    listNotification.setCacheColorHint(0);


    swipeLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
    swipeLayout.setOnRefreshListener(this);
    swipeLayout.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light);

    if (Global.notifications == null) {
        swipeLayout.setRefreshing(true);
        new GetNotificationList().execute();
    }
    LoadNotificationToListView();
Run Code Online (Sandbox Code Playgroud)

在刷新

 @Override
public void onRefresh() {

    new GetNotificationList().execute();
}
Run Code Online (Sandbox Code Playgroud)

android pull-to-refresh

4
推荐指数
1
解决办法
3344
查看次数