gpt4 book ai didi

android - iconitemrenderer 可点击对象?

转载 作者:行者123 更新时间:2023-11-29 18:19:02 25 4
gpt4 key购买 nike

我正在 Flash Builder 4.5 中为 android 和 iOS 制作一个移动应用程序,并使用 itemRenderer 和 iconitemrenderer 类为我的应用程序制作一个选项列表。出于某种原因,我无法让它们可点击,也无法定义点击每个按钮时要执行的操作。基本上,我的目标是使用 FB 的“ View ”,并在单击某个项目时切换到新 View 。这是我正在使用的代码:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:ms="libs/MessageBox-digitalRetro">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:actionContent>
<s:Button id="signin" label="Sign in" click="onSignIn(event)"/>
</s:actionContent>
//code for the clicking of the sign in button
<fx:Script>
<![CDATA[
protected function onSignIn(event:Event):void
{

}
]]>
</fx:Script>
<s:List height="100%" width="100%">
<s:itemRenderer>
<fx:Component>
<s:IconItemRenderer height="100" labelField="name"
iconField="photo" iconHeight="80"
iconWidth="80" messageFunction="getMessage">
<fx:Script>
<![CDATA[
import spark.components.NavigatorContent;
//this first method works
protected function getMessage(o:Object):String
{
return o.message;
}
]]>
</fx:Script>
</s:IconItemRenderer>
</fx:Component>
</s:itemRenderer>
<s:dataProvider>
<s:ArrayCollection>
<fx:Object name="Projects" photo="@Embed('libs/ProjectsIcon2.png')" message="Learn more about what we're working on" clickfn="views/Projects"/>
<fx:Object name="Locate Office" photo="@Embed('libs/google-maps-icon.png')" message="Find directions to our nearest office" clickfn=""/>
<fx:Object name="Contact Us" photo="@Embed('libs/gmailicon.png')" message="Let us know your thoughts!" clickfn=""/>
<fx:Object name="About Us" photo="@Embed('libs/info-icon.png')" message="" clickfn=""/>
</s:ArrayCollection>
</s:dataProvider>
<s:change>
<![CDATA[
// NEW!!!
var ClassReference:Class = getDefinitionByName(event.currentTarget.selectedItem.clickfn) as Class;
navigator.pushView(ClassReference);
]]>
</s:change>
</s:List>
</s:View>

编辑:我添加了“change”标签,它现在可以编译,但我收到一条错误消息:

ReferenceError:错误#1065: undefined variable 项目。 在全局/flash.utils::getDefinitionByName() 在 View ::MainHomeView/___MainHomeView_List1_change()[C:\Users\jlehenbauer\Adobe Flash Builder 4.5\Metters Inc\src\views\MainHomeView.mxml:56] 在 flash.events::EventDispatcher/dispatchEventFunction() 在 flash.events::EventDispatcher/dispatchEvent() 在 mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:13128] 在 spark.components::List/commitSelection()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\List.as:1205] 在 spark.components.supportClasses::ListBase/commitProperties()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\supportClasses\ListBase.as:939] 在 spark.components::List/commitProperties()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\List.as:1069] 在 mx.core::UIComponent/validateProperties()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:8209] 在 mx.managers::LayoutManager/validateProperties()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:597] 在 mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:813] 在 mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]

最佳答案

您可以通过执行以下操作来简化 JacobL 的回答中的更改处理程序逻辑:

<s:List id="list1" height="100%" width="100%" change="navigator.pushView(list1.selectedItem.nextView)">
<s:itemRenderer>
<fx:Component>
<s:IconItemRenderer labelField="name"/>
</fx:Component>
</s:itemRenderer>
<s:dataProvider>
<s:ArrayList>
<s:DataItem name="Projects" message="Learn more about what we're working on" nextView="{views.Projects}" />
<s:DataItem name="Locate Office" message="Find directions to our nearest office" nextView="{views.Locate}" />
<s:DataItem name="Contact Us" message="Let us know your thoughts!" nextView="{views.ContactUs}" />
<s:DataItem name="About Us" message="" nextView="{views.AboutUs}" />
</s:ArrayList>
</s:dataProvider>
</s:List>

关于android - iconitemrenderer 可点击对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6520784/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com