Class ccui.ListView
- Defined in: UIListView.js
- Extends ccui.ScrollView
Constructor Attributes | Constructor Name and Description |
---|---|
The list view control of Cocos UI.
|
Method Summary
Class Detail
ccui.ListView()
The list view control of Cocos UI.
var listView = new ccui.ListView(); // set list view ex direction listView.setDirection(ccui.ScrollView.DIR_VERTICAL); listView.setTouchEnabled(true); listView.setBounceEnabled(true); listView.setBackGroundImage("res/cocosui/green_edit.png"); listView.setBackGroundImageScale9Enabled(true); listView.setContentSize(cc.size(240, 130)); this.addChild(listView);
Field Detail
<static> <constant>
ccui.ListView.EVENT_SELECTED_ITEM
The flag selected item of ccui.ListView's event.
<static> <constant>
ccui.ListView.GRAVITY_BOTTOM
The bottom flag of ccui.ListView's gravity.
<static> <constant>
ccui.ListView.GRAVITY_CENTER_HORIZONTAL
The center horizontal flag of ccui.ListView's gravity.
<static> <constant>
ccui.ListView.GRAVITY_CENTER_VERTICAL
The center vertical flag of ccui.ListView's gravity.
<static> <constant>
ccui.ListView.GRAVITY_LEFT
The left flag of ccui.ListView's gravity.
<static> <constant>
ccui.ListView.GRAVITY_RIGHT
The right flag of ccui.ListView's gravity.
<static> <constant>
ccui.ListView.GRAVITY_TOP
The top flag of ccui.ListView's gravity.
<static> <constant>
ccui.ListView.ON_SELECTED_ITEM_END
The flag selected item end of ccui.ListView's event.
<static> <constant>
ccui.ListView.ON_SELECTED_ITEM_START
The flag selected item start of ccui.ListView's event.
Method Detail
-
addChild(widget, zOrder, tag)add child to ListView
- Parameters:
- {cc.Node} widget
- {Number} zOrder Optional
- {Number|String} tag Optional
- tag or name
-
addEventListener(selector, target)Adds event listener to ccui.ListView.
- Parameters:
- {Function} selector
- {Object} target Optional
-
addEventListenerListView(selector, target)Adds event listener to ccui.ListView.
- Parameters:
- {Function} selector
- {Object} target Optional
- Deprecated:
- since v3.0, please use addEventListener instead.
-
<static> ccui.ListView.create()allocates and initializes a UIListView.
- Deprecated:
- since v3.0, please use new ccui.ListView() instead.
-
ctor()allocates and initializes a UIListView. Constructor of ccui.ListView, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
// example var aListView = new ccui.ListView();
-
doLayout()provides a public _doLayout function for Editor. it calls _doLayout.
-
{number} getCurSelectedIndex()Returns current selected index
- Returns:
- {number}
-
{string} getDescription()Returns the "class name" of ccui.ListView.
- Returns:
- {string}
-
{Number} getIndex(item)Returns the index of item.
- Parameters:
- {ccui.Widget} item
- the item which need to be checked.
- Returns:
- {Number} the index of item.
-
{ccui.Widget} getItem(index)Returns a item whose index is same as the parameter.
- Parameters:
- {Number} index
- Returns:
- {ccui.Widget}
-
{Array} getItems()Returns the item container.
- Returns:
- {Array}
-
{Number} getItemsMargin()Returns the margin between each item.
- Returns:
- {Number}
-
{boolean} init()Initializes a ccui.ListView. Please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
- Returns:
- {boolean}
-
insertCustomItem(item, index)Push back custom item into ccui.ListView.
- Parameters:
- {ccui.Widget} item
- {Number} index
-
insertDefaultItem(index)Insert a default item(create by a cloned model) into ListView.
- Parameters:
- {Number} index
-
interceptTouchEvent(eventType, sender, touch)Intercept touch event, handle its child's touch event.
- Parameters:
- {Number} eventType
- {ccui.Widget} sender
- {cc.Touch} touch
-
pushBackCustomItem(item)Push back custom item into ListView.
- Parameters:
- {ccui.Widget} item
-
pushBackDefaultItem()Push back a default item(create by a cloned model) into ListView.
-
refreshView()Refreshes list view.
-
removeAllChildren()Removes all children from ccui.ListView.
-
removeAllChildrenWithCleanup(cleanup)Removes all children from ccui.ListView and do a cleanup all running actions depending on the cleanup parameter.
- Parameters:
- {Boolean} cleanup
-
removeAllItems()Removes all items from ccui.ListView.
-
removeChild(widget, cleanup)remove child from ListView
- Parameters:
- {cc.Node} widget
- {Boolean} cleanup Optional, Default: true
-
removeItem(index)Removes a item whose index is same as the parameter.
- Parameters:
- {Number} index
-
removeLastItem()Removes the last item of ccui.ListView.
-
requestRefreshView()Requests refresh list view.
-
setDirection(dir)Changes scroll direction of ccui.ListView.
- Parameters:
- {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH} dir
-
setGravity(gravity)Changes the gravity of ListView.
-
setItemModel(model)Sets a item model for ListView. A model will be cloned for adding default item.
- Parameters:
- {ccui.Widget} model
-
setItemsMargin(margin)Changes the margin between each item.
- Parameters:
- {Number} margin