看來,gridview的onitemselected行爲是由Android控制的,我怎樣才能禁用一些項目來回調onItemSelected()?Android,如何禁用一些項目上的GridView的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();
}
我使用onItemSelected()來改變項目的背景就像一個重點,因爲我的d-墊導航。而且我不想在位置3之後調用onItemSelected()並將焦點放在位置3.謝謝!
你就不能忽略的一些看法回調(添加某種條件開始時)? –
謝謝,我可以忽略'因爲我使用D-pad導航,我使用onItemSelected在位置3之前更改項目的背景。 – herbertD