-2

I am using DataSet to get & set the value. Now I need to implement SearchView for filtering. SearchQuery is passed like "abcd". But how I compare "abcd" String with the datas are in List DataSet. I tried to get it by using contains & equals. But it didn't work.

private void SEARCH_QUERY(String strSearch) {

    String NEWTEXT = strSearch.trim();

    if (RestaurantDataSet.equals(NEWTEXT)) {

        RestaurantDataSet = new ArrayList<>();

        for (int i = 0; i < RestaurantDataSet.size(); i++) {

            String PRODUCTID = String.valueOf(RestaurantDataSet.get(i).getIG_PRODUCTID());
            String PRODUCTNAME = RestaurantDataSet.get(i).getIG_PRODUCTNAME();
            String CATEGORY_NAME = RestaurantDataSet.get(i).getIG_CATEGORYNAME();
            String CAT_ID = RestaurantDataSet.get(i).getIG_CATEGORY_ID();
            String IMG_ID = String.valueOf(RestaurantDataSet.get(i).getIG_IMAGEURL());
            int LIKE = RestaurantDataSet.get(i).getIG_LIKECOUNT();
            String PRICE = RestaurantDataSet.get(i).getIG_SALES_PRICE();
            String VOUCHER_ID = RestaurantDataSet.get(i).getIG_VOUCHER_ID();

            Restaurant_Beam item = new Restaurant_Beam();

            item.setIG_LIKECOUNT(LIKE);
            item.setIG_PRODUCTID(PRODUCTID);
            item.setIG_SALES_PRICE(PRICE);
            item.setIG_VOUCHER_ID(VOUCHER_ID);
            item.setIG_CATEGORY_ID(CAT_ID);
            item.setIG_IMAGEURL(IMG_ID);
            item.setIG_PRODUCTNAME(PRODUCTNAME);
            item.setIG_CATEGORYNAME(CATEGORY_NAME);

            RestaurantDataSet.add(item);
        }

        adapter = new CardAdapter(RestaurantDataSet, context);
        recyclerView.setAdapter(adapter);
        adapter.notifyDataSetChanged();
    }
}

Understanding pointers. What does *((char **) equal to?

In C, I have:

char *p, *q;
p = malloc(1);  //for the purpose testing only
p[0] = '!';
q = *((char **)p);
printf("p=%x q=%x\n", p, q);
printf("p=%c q=%c\n", p, q);

There were no casting warnings, and the output is:

p=1a9008 q=21
p q=!

What happens in the expression assigned to q, ie *((char **)p)? Has the type of q changed after the assignment?


Edits: there is an error in my code. While trying to distil it from a code fragment I came across into a fully working example, I wrongly used an example value of type char for p. After examining more of the original code, p was assigned a pointer value. So p is a pointer to a pointer.

4

2 回答 2

1

Recyclerview 基本上是列表视图的高级版本。它具有 ListView 的所有功能,并且在处理大数据集时比 ListView 更灵活。在 RecyclerView 中添加搜索功能可以使用户能够从大量数据集合中搜索/过滤关键字,而无需滚动列表直到找到所需的实体。答案和示例代码 Stackoverflow 和 github

于 2016-04-02T12:49:53.787 回答
1

此处提供了完整的解决方案,用于在您的应用中获取搜索操作。为搜索提供了分步实施,如果您仍然需要任何说明,您可以询问。请检查

如何使用 SearchView 过滤 RecyclerView

于 2016-04-02T11:44:08.003 回答