예제 #1
0
/**
 * Show currently used selection style for an list view item.
 * Works on iOS platform.
 */
void SettingsScreen::showSelectionStyleMessageBox()
{
	MAUtil::String textToShow;
	if (mListView->countChildWidgets() == 0)
	{
		textToShow = "The list view section does not have sections.";
	}
	else
	{
		ListViewSection* section = (ListViewSection*) mListView->getChild(0);
		if (section->countChildWidgets() == 0)
		{
			textToShow = "The list view section does not have items.";
		}
		else
		{
			ListViewItem* item = (ListViewItem*) section->getChild(0);
			ListViewItemSelectionStyle selectionStyle =
				item->getSelectionStyle();
			textToShow = "The selection style is: " +
				getSelectionStyleString(selectionStyle);
		}
	}
	maAlert("ListViewItem selection style", textToShow.c_str(), "OK", NULL, NULL);
}
예제 #2
0
/**
 * Change all the list view's items selection style to a given value.
 * @param style Style to set.
 */
void SettingsScreen::changeSelectionStyle(ListViewItemSelectionStyle style)
{
	int sectionIndex = 0;
	int countSections = mListView->countChildWidgets();

	while (sectionIndex < countSections)
	{
		ListViewSection* section = (ListViewSection*) mListView->getChild(sectionIndex);
		int itemIndex = 0;
		int countItems = section->countChildWidgets();

		while (itemIndex < countItems)
		{
			ListViewItem* item = (ListViewItem*) section->getChild(itemIndex);
			item->setSelectionStyle(style);

			itemIndex++;
		}

		sectionIndex++;
	}
}
예제 #3
0
/**
 * This method is called if the touch-up event was inside the
 * bounds of the button.
 * Platform: iOS, Android and Windows Phone 7.
 * @param button The button object that generated the event.
 */
void ListScreen::buttonClicked(Widget* button)
{
	if (button == mReloadData)
	{
		mListView->reloadData();
	}
	else if (button == mRemoveFirstSection)
	{
		if (mListView->countChildWidgets() > 0)
		{
			mListView->removeChild(mListView->getChild(0));
		}
	}
	else if (button == mRemoveItem)
	{
		if (mListView->countChildWidgets() > 0)
		{
			ListViewSection* firstSection = (ListViewSection*)mListView->getChild(0);
			if (firstSection->countChildWidgets() > 0)
			{
				firstSection->removeItem(0);
			}
		}
	}
	else if (button == mAddItem)
	{
		if (mListView->countChildWidgets() > 0)
		{
			ListViewSection* firstSection = (ListViewSection*)mListView->getChild(0);
			ListViewItem* newItem = new ListViewItem();
			newItem->setText("testItem");
			newItem->setSubtitle("subtitle");
			firstSection->insertItem(newItem, 0);
		}
	}
}