Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用“编辑文本”在多级回收视图中搜索不起作用 我正在尝试实现搜索功能_Android_Search - Fatal编程技术网

Android 使用“编辑文本”在多级回收视图中搜索不起作用 我正在尝试实现搜索功能

Android 使用“编辑文本”在多级回收视图中搜索不起作用 我正在尝试实现搜索功能,android,search,Android,Search,我有两个回收视图,一个是水平的,一个是垂直的。当我搜索我得到这个结果屏幕,请检查我不知道我做错了什么,请帮助我 我的片段类 专用无效过滤器(字符串文本){ ArrayList temp=新的ArrayList(); 用于(仪表板服务d:dataModelList){ //或者使用.equal(文本)与您想要的相等匹配 //使用.toLowerCase()进行更好的匹配 if(d.getName().toLowerCase().contains(text.toLowerCase().toStr

我有两个回收视图,一个是水平的,一个是垂直的。当我搜索我得到这个结果屏幕,请检查我不知道我做错了什么,请帮助我


我的片段类
专用无效过滤器(字符串文本){
ArrayList temp=新的ArrayList();
用于(仪表板服务d:dataModelList){
//或者使用.equal(文本)与您想要的相等匹配
//使用.toLowerCase()进行更好的匹配
if(d.getName().toLowerCase().contains(text.toLowerCase().toString()))
{
温度添加(d);
}
}
//更新回收视图
frSevicesAdapter.updateList(临时);
}
------------------------我的第一个适配器----------------
@凌驾
公共FrServicesRecyclerAdapter.ViewHolder onCreateViewHolder(视图组父级、,
int视图类型){
绑定=数据绑定直到。充气(
LayoutInflater.from(parent.getContext()),
R.layout.adapter\u dashboard\u服务,父级,false);
返回新的视图持有者(绑定);
}
@凌驾
公共无效onBindViewHolder(ViewHolder,int位置){
DashboardServices dataModel=mainTitleArrayListFiltered.get(位置);
ArrayList subTitleArrayList=mainTitleArrayListFiltered.get(位置).getChildren();
binding.setDataModel(dataModel);
LinearLayoutManager LinearLayoutManager=新的LinearLayoutManager(上下文,LinearLayoutManager.HORIZONTAL,false);
binding.recycleView.setLayoutManager(linearLayoutManager);
frServicesInsideAdapter=新的frServicesInsideAdapter(SubtitaryList,上下文);
binding.setAdapter(frServicesInsideAdapter);
}
@凌驾
public int getItemCount(){
return maintTitlearRayListFiltered==null?0:maintTitlearRayListFiltered.size();
}
公共无效更新列表(ArrayList临时){
mainTitleArrayListFiltered.clear();
mainTitleArrayListFiltered=温度;
notifyDataSetChanged();
}
类ViewHolder扩展了RecyclerView.ViewHolder{
AdapterDashboardServiceBinding项RowBinding;
视图H#####标题##旧(AdapterDashboardServiceBinding itemRowBinding){
super(itemRowBinding.getRoot());
this.itemRowBinding=itemRowBinding;
}
}
------------------我的第二个内部适配器----------------

公共FrServicesInsideAdapter(ArrayList dataModelList,上下文){
this.dataModelList=dataModelList;
this.context=上下文;
}
@凌驾
公共FrServicesInsideAdapter.ViewHolder onCreateViewHolder(视图组父级、,
int视图类型){
AdapterItemViewBinding=DataBindingUtil.inflate(
LayoutInflater.from(parent.getContext()),
R.layout.adapter\u item\u视图,父级,false);
返回新的视图持有者(绑定);
}
@凌驾
公共无效onBindViewHolder(ViewHolder,int位置){
DashboardServices dataModel=dataModelList.get(位置);
holder.bind(数据模型);
}
@凌驾
public int getItemCount(){
返回dataModelList==null?0:dataModelList.size();
}
类ViewHolder扩展了RecyclerView.ViewHolder{
AdapterItemViewBinding项RowBinding;
ViewHolder(AdapterItemViewBinding项RowBinding){
super(itemRowBinding.getRoot());
this.itemRowBinding=itemRowBinding;
}
无效绑定(仪表板服务对象){
itemRowBinding.setModel(obj);
itemRowBinding.executePendingBindings();
}
}

当我调试代码时,我的内部适配器的
getItemCount
方法没有被调用。我不知道为什么它没有被调用,并且我得到了不同的结果。我已经分享了屏幕截图。请检查是否需要任何东西。

屏幕截图在哪里?请正确编辑代码和标签,以提供更多的逻辑和格式,以便so中的人员可以帮助您!你现在能查一下吗?你清楚了吗。
         My Fragment class
        
         private void filter(String text) {
                ArrayList<DashboardServices> temp = new ArrayList<>();
                for (DashboardServices d : dataModelList) {
                    //or use .equal(text) with you want equal match
                    //use .toLowerCase() for better matches
                    if (d.getName().toLowerCase().contains(text.toLowerCase().toString()))
    {
                        temp.add(d);
                    }
                }
                //update recyclerview
                frSevicesAdapter.updateList(temp);
            }
             ------------------------My First Adapter----------------
            @Override
            public FrServicesRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                                           int viewType) {
                binding = DataBindingUtil.inflate(
                        LayoutInflater.from(parent.getContext()),
                        R.layout.adapter_dashboard_service, parent, false);
                return new ViewHolder(binding);
        
            }
        
            @Override
            public void onBindViewHolder(ViewHolder holder, int position) {
        
                DashboardServices dataModel = mainTitleArrayListFiltered.get(position);
                ArrayList<DashboardServices> subTitleArrayList = mainTitleArrayListFiltered.get(position).getChildren();
                binding.setDataModel(dataModel);
                LinearLayoutManager linearLayoutManager=new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL,false);
                binding.recycleView.setLayoutManager(linearLayoutManager);
                frServicesInsideAdapter = new FrServicesInsideAdapter(subTitleArrayList, context);
                binding.setAdapter(frServicesInsideAdapter);
        
        
            }
        
        
            @Override
            public int getItemCount() {
                return mainTitleArrayListFiltered == null ? 0 : mainTitleArrayListFiltered.size();
            }
        
            public void updateList(ArrayList<DashboardServices> temp) {
                mainTitleArrayListFiltered.clear();
                mainTitleArrayListFiltered = temp;
                notifyDataSetChanged();
            }
        
            class ViewHolder extends RecyclerView.ViewHolder {
                AdapterDashboardServiceBinding itemRowBinding;
        
                ViewH## Heading ##older(AdapterDashboardServiceBinding itemRowBinding) {
                    super(itemRowBinding.getRoot());
                    this.itemRowBinding = itemRowBinding;
                }
        
            }
 public FrServicesInsideAdapter(ArrayList<DashboardServices> dataModelList, Context context) {

        this.dataModelList = dataModelList;
        this.context = context;

    }

    @Override
    public FrServicesInsideAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                                 int viewType) {
        AdapterItemViewBinding binding = DataBindingUtil.inflate(
                LayoutInflater.from(parent.getContext()),
                R.layout.adapter_item_view, parent, false);

        return new ViewHolder(binding);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        DashboardServices dataModel = dataModelList.get(position);
        holder.bind(dataModel);
    }


    @Override
    public int getItemCount() {
        return dataModelList == null ? 0 : dataModelList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        AdapterItemViewBinding itemRowBinding;

        ViewHolder(AdapterItemViewBinding itemRowBinding) {
            super(itemRowBinding.getRoot());
            this.itemRowBinding = itemRowBinding;
        }

        void bind(DashboardServices obj) {
            itemRowBinding.setModel(obj);
            itemRowBinding.executePendingBindings();
        }
    }