gpt4 book ai didi

java - 重写 AbsListView.MultiChoiceModeListener 中的 onItemCheckedStateChanged()

转载 作者:行者123 更新时间:2023-12-02 11:05:01 29 4
gpt4 key购买 nike

代码如下:

    mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
mListView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener(){

@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean
checked) {
}

@Override
private boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.cam_menu, menu);
return true;
}

@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_item_delete_reminder:
for (int nC = mCursorAdapter.getCount() - 1; nC >= 0; nC--) {
if (mListView.isItemChecked(nC)) {
mDbAdapter.deleteReminderById(getIdFromPosition(nC));
}
}
mode.finish();
mCursorAdapter.changeCursor(mDbAdapter.fetchAllReminders());
return true;
}
return false;
}

@Override
public void onDestroyActionMode(ActionMode mode) {
}
});
}

这是 Gerber 和 Craig 所著的《学习 Android Studio》一书中的示例。我收到错误:不是抽象的,并且不会覆盖 MultiChoiceModeListener 中的抽象方法 onItemCheckedStateChanged(ActionMode,int,long,boolean)。

最佳答案

Alt + Enter(在 Android Studio 中)导入 导入android.support.v7.view.ActionMode;我把它改为 android.view.ActionMode

在这里找到信息: https://forums.bignerdranch.com/t/multichoicemodelistener-problem/6106

关于java - 重写 AbsListView.MultiChoiceModeListener 中的 onItemCheckedStateChanged(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51042764/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com