public override bool remove(ControlUI pControl) { int iIndex = getItemIndex(pControl); if (iIndex == -1) { return(false); } if (!base.removeAt(iIndex)) { return(false); } for (int i = iIndex; i < getCount(); ++i) { ControlUI p = getItemAt(i); IListItemUI pListItem = (IListItemUI)p.getInterface("ListItem"); if (pListItem != null) { pListItem.setIndex(pListItem.getIndex() - 1); } } selectItem(findSelectable(mCurSel, false)); return(true); }
public override bool addAt(ControlUI pControl, int iIndex) { if (!base.addAt(pControl, iIndex)) { return(false); } // 所有的列表项目都是我们指定的 IListItemUI pListItem = (IListItemUI)pControl.getInterface("ListItem"); if (pListItem != null) { pListItem.setOwner(this); pListItem.setIndex(iIndex); } for (int i = iIndex + 1; i < getCount(); ++i) { ControlUI p = getItemAt(i); pListItem = (IListItemUI)p.getInterface("ListItem"); if (pListItem != null) { pListItem.setIndex(pListItem.getIndex() + 1); } } return(true); }
public override bool setItemIndex(ControlUI pControl, int iIndex) { if (pControl.getInterface("ListHeader") != null) { return(base.setItemIndex(pControl, iIndex)); } // We also need to recognize header sub-items if (pControl.getClass() == "ListHeaderItemUI") { return(mHeader.setItemIndex(pControl, iIndex)); } int iOrginIndex = mList.getItemIndex(pControl); if (iOrginIndex == -1) { return(false); } if (!mList.setItemIndex(pControl, iIndex)) { return(false); } // The list items should know about us IListItemUI pListItem = (IListItemUI)pControl.getInterface("ListItem"); if (pListItem != null) { pListItem.setIndex(getCount()); } for (int i = iOrginIndex; i < mList.getCount(); ++i) { ControlUI p = mList.getItemAt(i); pListItem = (IListItemUI)(p.getInterface("ListItem")); if (pListItem != null) { pListItem.setIndex(pListItem.getIndex() - 1); } } selectItem(findSelectable(mCurSel, false)); ensureVisible(mCurSel); return(true); }
public override bool addAt(ControlUI pControl, int iIndex) { // Override the AddAt() method so we can add items specifically to // the intended widgets. Headers and are assumed to be // answer the correct interface so we can add multiple list headers. if (pControl.getInterface("ListHeader") != null) { return(base.addAt(pControl, iIndex)); } // We also need to recognize header sub-items if (pControl.getClass() == "ListHeaderItemUI") { return(mHeader.addAt(pControl, iIndex)); } if (!mList.addAt(pControl, iIndex)) { return(false); } // The list items should know about us IListItemUI pListItem = (IListItemUI)pControl.getInterface("ListItem"); if (pListItem != null) { pListItem.setOwner(this); pListItem.setIndex(iIndex); } for (int i = iIndex + 1; i < mList.getCount(); ++i) { ControlUI p = mList.getItemAt(i); pListItem = (IListItemUI)p.getInterface("ListItem"); if (pListItem != null) { pListItem.setIndex(pListItem.getIndex() + 1); } } return(true); }
public override bool removeAt(int iIndex) { if (!mList.removeAt(iIndex)) { return(false); } for (int i = iIndex; i < mList.getCount(); ++i) { ControlUI p = mList.getItemAt(i); IListItemUI pListItem = (IListItemUI)p.getInterface("ListItem"); if (pListItem != null) { pListItem.setIndex(pListItem.getIndex() - 1); } } selectItem(findSelectable(mCurSel, false)); ensureVisible(mCurSel); return(true); }
public override bool remove(ControlUI pControl) { if (pControl.getInterface("ListHeader") != null) { return(base.remove(pControl)); } // We also need to recognize header sub-items if (pControl.getClass() == "ListHeaderItemUI") { return(mHeader.remove(pControl)); } int iIndex = mList.getItemIndex(pControl); if (iIndex == -1) { return(false); } if (!mList.removeAt(iIndex)) { return(false); } for (int i = iIndex; i < mList.getCount(); ++i) { ControlUI p = mList.getItemAt(i); IListItemUI pListItem = (IListItemUI)p.getInterface("ListItem"); if (pListItem != null) { pListItem.setIndex(pListItem.getIndex() - 1); } } selectItem(findSelectable(mCurSel, false)); ensureVisible(mCurSel); return(true); }