Ref* CTableViewReloadTest::tableviewDataSource(Ref* pConvertView, unsigned int idx) { CTableViewCell* pCell = (CTableViewCell*) pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CTableViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(150.0f / 2, 54.0f / 2)); // pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } pButton->getLabel()->setString(m_vDatas[idx].c_str()); pButton->setUserTag(idx); return pCell; }
Ref* CTableViewBasicTest::tableviewDataSource(Ref* pConvertView, unsigned int idx) { CTableViewCell* pCell = (CTableViewCell*)pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CTableViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(Size(70, 70), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(74.0f / 2, 70.0f / 2)); //pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } char buff[64]; sprintf(buff, "%u", idx); pButton->getLabel()->setString(buff); pButton->setUserTag(idx); return pCell; }
CCObject* CTableViewBindingDataAndVertical::tableviewDataSource(CCObject* pConvertView, unsigned int idx) { CTableViewCell* pCell = (CTableViewCell*)pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CTableViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(CCSizeMake(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setOnClickListener(this, ccw_click_selector(CTableViewBindingDataAndVertical::onClick)); pButton->setPosition(CCPoint(150.0f / 2, 54.0f / 2)); pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } pButton->getLabel()->setString(m_vDatas[idx].c_str()); pButton->setUserTag(idx); return pCell; }