what to use in Android for UIPicker like functionality

In my app i have to give control to choose from 100 pre-sets.

  • in IOS port I am binging up action sheet with UIPicker view added to it so that it shows popover on top of cocos2d-x view
  • and after the selection from 100 options it vanishes.

now i want to do similar thing for android. but I am stuck on

  • how to bring in action sheet like popover view on top of cocos2d-x view and display some picker like android native control.

Any suggestions, views ?

thanks,
digish

If you only want to using the pickerview function, I suggest you can use the cocos2d extensions, just implement your self. It is so easy to have self cross-platform PickerView.

Thanks for your view.

I finally made my own picker view control using CCTableview and CCButton.
however it looks CCTableview scroll is not behaving properly if it’s width kept same as parent layer i had to reduce the size by 100 to make it work correctly

any inputs on who to select size of CCTableView when it’s parent layer is not full screen it’s small popup window

@digish pandya: CCTableview not scrolling at all.

Hi digish,
I am implementing CCTableview with each cell as PNG image. CCTableView is not getting scrolled on android devices.

Also I tried with reducing size by 100 as earlier it was same as devices width. Bt not working on many devices I tested. :frowning:

Any another solution.

Actually you maybe don’t something wrong. The CCTableview in Android will work correctly. Can you post some code what you are writing?

Maybe it is not the CCTableview problem.

If you really confuse of CCTableview, you can make with CCScrollview and control the resource loading with for loop, and handle the CCTouchDisaptch delegate, to control the scrollview content how to scroll , something like page enable in UIScrollview.

#include “LevelScene.h”

USING_NS_CC;
USING_NS_CC_EXT;

LevelScene::LevelScene() :
mLevelTable(NULL), mLevelsArray(NULL)
{
}

LevelScene::~LevelScene()
{
CC_SAFE_RELEASE(mLevelsArray);
CC_SAFE_RELEASE(mLevelTable);
}

SEL_MenuHandler LevelScene::onResolveCCBCCMenuItemSelector(CCObject * pTarget, const char * pSelectorName) {
return NULL;
}

SEL_CCControlHandler LevelScene::onResolveCCBCCControlSelector(
CCObject * pTarget, const char * pSelectorName)
{
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, “homeClicked”, LevelScene::homeClicked);

return NULL;
}

void LevelScene::onEnter()
{

this~~>mLevelTable = CCTableView::create);
this~~>mLevelTable~~>setAnchorPoint;
this~~>mLevelTable~~>setDirection;
this~~>mLevelTable~~>setPosition);
this~~>mLevelTable~~>setDelegate;
this~~>mLevelTable~~>setDataSource;
this~~>mLevelTable~~>setVerticalFillOrder;
this~~>addChild(this~~>mLevelTable);
this~~>mLevelTable~~>reloadData;

}
void LevelScene::homeClicked
{
switch
{
case CCControlEventTouchUpInside:
CCDirector::sharedDirector~~>popScene;
break;
}
}
/***
** cell height for a given table.
*
* `param table table to hold the instances of Class

  • return cell size **/ CCSize LevelScene::cellSizeForTable { return CCSizeMake; } /**\* \* a cell instance at a given index \* \*param idx index to search for a cell
  • `return cell found at idx
    /
    CCTableViewCell
    LevelScene::tableCellAtIndex
    {
    CCTableViewCell * mCell = table~~>dequeueCell;
    if
    {
    mCell = new CCTableViewCell;
    mCell~~>autorelease();
    }
    else
    {
    mCell~~>removeAllChildrenWithCleanup;
    }
    CCSprite * mBackSprite;
    mBackSprite = CCSprite::create;
    mBackSprite~~>setPosition(CCPointMake(0,15));
    mBackSprite
    >setAnchorPoint(CCPointZero);

CCSprite *mCarSprite;
mCarSprite = CCSprite::create(“car_green.png”);
mCarSprite~~>setPosition);
mCarSprite~~>setAnchorPoint(CCPointZero);

mBackSprite~~>addChild;
CCLabelTTF * pLevel = CCLabelTTF::create;
CCString * pString = CCString::createWithFormat;
CCString sLevel = CCString::createWithFormat);
pLevel~~>setString);
pLevel~~>setPosition);
mBackSprite~~>addChild;
mCell~~>addChild;
return mCell;
}
/
*
* Returns number of cells in a given table view.
*
* `return number of cells
*/
unsigned int LevelScene::numberOfCellsInTableView(CCTableView *table)
{
return 7;
}

/**

  • Delegate to respond touch event
  • `param table table contains the given cell
    * @param cell cell that is touched
    */
    void LevelScene::tableCellTouched
    {
    }
    void LevelScene::scrollViewDidScroll
    {
    view~~>setDelegate(this);
    view->setDirection(kCCScrollViewDirectionVertical);
    }

@Victor Desuza, I got my code for picker view working perfect now size and scrolling issue is also resolved.
I am writing a sample code for picker view I will share soon.

@Victor Desuza, BTW have you tried the CCTableView sample under extension test from TestCPP project ?
it is doing same like having png in cell

@ digish : Namaste

Yup I tried that code only which you are talking about (TestCpp project).

I am tested that with different android devices. But table is not scrolling at all. I dont knw wat’s d issue.

Finally I solved CCTableView scrolling issue.

I overrided method onEnter() method in my cpp file.

And I forgot to add (/) (/) (/) CCLayer::onEnter() which is calling super class constructor. :slight_smile: :slight_smile: :slight_smile:

any sample to check this ui picker view kind component in cocos2d-x??

digish pandya wrote:

@Victor Desuza, I got my code for picker view working perfect now size and scrolling issue is also resolved.
I am writing a sample code for picker view I will share soon.