列表中采用了android列表片段适配器顶部最常选择的项目(3项)? [英] List most frequently selected items(3 items) at top of the adapter using android list fragments?

查看:195
本文介绍了列表中采用了android列表片段适配器顶部最常选择的项目(3项)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用列表片段列表视图显示制造项目。为此,我已经为列表出来的项的制造适配器,它列出超过百余项。现在,我的要求是,以显示在列表顶部的大多是经常选择的项目(三个项目更够)。

I've used list fragment and list view for displaying manufacture items. For that I've created a manufacture adapter for list out the items and it list more than hundred items. Now My requirement is to show the mostly frequently selected items( three items more enough) at the top of list.

 getListView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ManufacturerListAdapter adapter = (ManufacturerListAdapter) getListAdapter();
            Cursor cursor = (Cursor) adapter.getItem(position);

            String manufacturerId = cursor.getString(cursor.getColumnIndex(ManufacturersColumns.MANUFACTURER_ID));
            int    isUserCreated  = cursor.getInt(cursor.getColumnIndex("usergen"));

            EditableItemActivity activity = (EditableItemActivity) getActivity();
            if (activity != null) activity.setManufacturer(manufacturerId, isUserCreated > 0);
            hideKeyboard();
        }

    });

我添加了对上市项目click事件的片段。希望它会更有助于理解我的要求。

I added a snippet of on click event of listed items. Hope it will more helpful to understand my requirement.

任何帮助将是AP preciated!

Any help would be appreciated!!!

推荐答案

ManufacturerListAdapter 将需要返回前几个行位置的大多是经常选择的项目(例如: , 0 1 2 ),用人在你希望的任何命令。

ManufacturerListAdapter will need to return those "mostly frequently selected items" for the first few row positions (e.g., 0, 1, and 2), with the others in whatever order you wish.

由于 ManufacturerListAdapter 似乎是的CursorAdapter 的一个子类,一种方法是:

Since ManufacturerListAdapter would appear to be a subclass of CursorAdapter, one approach is:


  • 请一个查询,让您的大多经常选择的项目为一个光标

  • 请另一个查询得到休息,在希望的顺序,进入另一个光标

  • 缝合两光标对象一起使用的 MergeCursor

  • 使用 MergeCursor ManufacturerListAdapter

  • Do one query to get your "mostly frequently selected items" into one Cursor
  • Do another query to get the rest, in the desired order, into another Cursor
  • Stitch the two Cursor objects together using a MergeCursor
  • Use the MergeCursor with your ManufacturerListAdapter

这篇关于列表中采用了android列表片段适配器顶部最常选择的项目(3项)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆