看来gridview的onitemselected的行为是由Android控制的,如何禁用某些项目来回调onItemSelected()?
我的代码:
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
if (view == null) return;
Utils.log(TAG, "view = " + view.toString() + ",pos = " + position + " , id =" + id);
//I want to disable onItemSelected after positon 3: (But I failed.)
if (position > 3) {
if (mLSV != null) {
onItemSelected(mGridView,mLSV, mLastPosition, mLastSelectedId);
return;
}
}
if (!mGridView.isFocused()) return;
if (mLSV != null) {
mLSV.setBackgroundColor(CMainUI_Model.BG_COLOR);
}
Utils.log(TAG, "onItemSelected, pos = " + position);
mLSV = view;
mLastPosition = position;
mLastSelectedId = mGridView.getSelectedItemId();
}
当我通过 D-pad 导航时,我使用 onItemSelected() 像焦点一样更改项目的背景。而且我不想在位置 3 之后调用 onItemSelected() 并且“焦点”停在位置 3。谢谢!