ActionMode:MultiChoiceListener不突出显示第一个项目

时间:2013-11-28 15:08:42

标签: java android android-actionbar android-actionmode

我在片段中有这个

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
        getListView().setMultiChoiceModeListener(new PlayerMultiChoiceListener(getListView(), getBaseActivity()));
        ...    
    }

这是实现

public abstract class PlayerMultiChoiceListener implements MultiChoiceModeListener {

    protected final ListView listView;
    protected final BaseActivity activity;
    protected final PlayerManager playerManager;

    public AbstractMultiChoiceListener(ListView listView, BaseActivity activity) {
        this.listView = listView;
        this.activity = activity;
        this.playerManager = PlayerManager.getInstance(activity);
    }

    ...

    @Override
    public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
        mode.setTitle(listView.getCheckedItemCount() + activity.getString(R.string.action_mode_title_selected));
        mode.getMenu().clear();
        if (listView.getCheckedItemCount() > 1) {
            mode.getMenuInflater().inflate(R.menu.list_actionmode, mode.getMenu());
        } else {
            mode.getMenuInflater().inflate(R.menu.list_actionmode_one_selected, mode.getMenu());
        }
        listView.getChildAt(position).setBackgroundResource(
                checked ? android.R.color.holo_blue_light : android.R.color.transparent);
    }

}

holo_blue_light未突出显示第一个选定项目(我长按以进入ActionMode的项目)。它被标记为已选中,并且执行了更改背景的代码但没有任何效果。接下来选择的项目会很好。有什么想法吗?

0 个答案:

没有答案