我有一个具有计算器名称数组的应用程序。选择后,我想推送该项目的计算器的实际视图。
这是我的代码可以有人帮我编写一个允许我这样做的函数吗?
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
title="iCalculate"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="creationCompleted(event)"
width="100%" height="100%">
<s:layout>
<s:VerticalLayout paddingTop="10"/>
</s:layout>
<fx:Script>
<![CDATA[
import com.Watts.collections.filter.Evaluator;
import com.Watts.demo.Album;
import mx.collections.ArrayCollection;
import mx.events.CollectionEvent;
import mx.events.FlexEvent;
import mx.rpc.http.Operation;
import spark.components.Image;
import spark.components.ViewMenu;
import spark.components.gridClasses.GridColumn;
import spark.events.IndexChangeEvent;
import spark.events.TextOperationEvent;
// Everything Below this line holds information specifically relating to Beta 2
// Below this line is the coding for the search bar or filter bar
private var _collection:ArrayCollection;
private var _evaluator:Evaluator = new Evaluator();
private function creationCompleted(event:FlexEvent):void
{
_collection = Album.collection;
_collection.filterFunction = filterCollection;
_evaluator.synonyms["four"] = new ArrayCollection(["4"]);
grid.dataProvider = _collection;
}
private function filterChanged(event:Event):void
{
update();
}
private function update():void
{
_evaluator.prepare(filter.text);
_collection.refresh();
formula.text = (_evaluator.tree) ? _evaluator.tree.toString() : "";
}
private function filterCollection(data:Object):Boolean
{
var labels:ArrayCollection = new ArrayCollection();
for (var i:int; i < grid.columns.length; i++)
{
labels.addItem((grid.columns.getItemAt(i) as GridColumn).itemToLabel(data));
}
return _evaluator.evaluate(labels);
}
]]>
</fx:Script>
<s:VGroup left="5" right="-9" top="5" bottom="5" width="100%" height="100%" textAlign="center">
<s:TextInput id="filter" width="100%" change="filterChanged(event)"/>
<s:DataGrid id="grid" width="100%" height="100%" textAlign="left">
</s:DataGrid>
<s:Label id="formula" />
</s:VGroup>
<s:Label id="lblWattsMessage" click="navigator.pushView(views.CompanyDetail)" color="#1021C7"
fontFamily="_typewriter" fontSize="12" text="Powered by WATTS Professionals"
textAlign="center" verticalAlign="middle"/>
</s:View>
答案 0 :(得分:2)
以下是我用来解决此问题的代码。在flex应用程序中,有一个可以使用的navigator.pushView组件。我遇到的问题是我没有为每个计算器分配视图ID。这必须在ArrayCollection容器中完成。
navigator.pushview( ViewID )