大家好,首先感谢您的关注和支持。我是弹性世界的初学者......我想做的事情可能太容易了,但我无法弄清楚。
我正在练习一个简单的移动应用程序,它利用数据库在 phpmyadmin 中创建并连接到我的移动项目。我想要做的是:当我单击任何列表项时,会弹出下一个视图,显示数据库表中所有文本输入中所选项目的值。我知道如何在我正在实现列表的视图中显示它,但是我收到一个错误,因为我在另一个视图中没有(也不想)列表项:
protected function list_changeHandler(event:IndexChangeEvent):void
{
titleTextInput.text = list.selectedItem.title;
dateIntro.selectedDate = list.selectedItem.date;
photoTextInput.text = list.selectedItem.photo;
descriptionTextInput.text = list.selectedItem.description;
}
但是我需要做什么才能在我的其他观点中获得相同的结果?
该项目有2个视图,
这是第一个视图
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:valueObjects="valueObjects.*"
xmlns:detallesservice="services.detallesservice.*" add="home(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import spark.events.IndexChangeEvent;
protected function button_clickHandler(event:MouseEvent):void
{
var detalles2:Detalles = new Detalles();
detalles2.title = titleTextInput.text;
detalles2.date = dateIntro.selectedDate;
detalles2.photo = photoTextInput.text;
detalles2.description = descriptionTextInput.text;
detallesService.createDetalles(detalles2);
detallesService.getAllDetalles();
}
protected function list_creationCompleteHandler(event:FlexEvent):void
{
getAllDetallesResult2.token = detallesService.getAllDetalles();
}
protected function button2_clickHandler(event:MouseEvent):void
{
detallesService.deleteDetalles(list.selectedItem.title);
}
protected function list_changeHandler(event:IndexChangeEvent):void
{
titleTextInput.text = list.selectedItem.title;
dateIntro.selectedDate = list.selectedItem.date;
photoTextInput.text = list.selectedItem.photo;
descriptionTextInput.text = list.selectedItem.description;
navigator.pushView(asyouwishView, list.selectedItem);
}
]]>
</fx:Script>
<fx:Declarations>
<valueObjects:Detalles id="detalles"/>
<detallesservice:DetallesService id="detallesService"/>
<s:CallResponder id="createDetallesResult"/>
<s:CallResponder id="getAllDetallesResult2"/>
<s:CallResponder id="deleteDetallesResult"/>
</fx:Declarations>
<s:List id="list" x="1100" y="142" width="716" height="372"
creationComplete="list_creationCompleteHandler(event)" labelField="title" change="list_changeHandler(event)">
<s:AsyncListView list="{getAllDetallesResult2.lastResult}"/>
</s:List>
<s:Form defaultButton="{button}">
<s:FormItem label="Title">
<s:TextInput id="titleTextInput" text="{detalles.title}"/>
</s:FormItem>
<s:FormItem width="800" label="Date">
<s:DateSpinner id="dateIntro" displayMode="date" selectedDate="{detalles.date}"/>
</s:FormItem>
<s:FormItem label="Photo">
<s:TextInput id="photoTextInput" text="{detalles.photo}"/>
</s:FormItem>
<s:FormItem label="Description">
<s:TextInput id="descriptionTextInput" text="{detalles.description}"/>
</s:FormItem>
<s:Button id="button" label="CreateDetalles" click="button_clickHandler(event)"/>
</s:Form>
<s:Form x="18" y="950">
<s:FormItem label="CreateDetalles">
<s:TextInput id="createDetallesTextInput"
text="{createDetallesResult.lastResult as String}"/>
</s:FormItem>
</s:Form>
<s:Button id="myDelete" x="1100" y="558" label="Delete" click="button2_clickHandler(event)"/>
这是第二种观点:
<fx:Script>
<![CDATA[
import spark.events.ViewNavigatorEvent;
protected function button_clickHandler(event:MouseEvent):void
{
// Please uncomment the below line if Data Management is enabled for Detalles and updateDetalles is used as the create function.
// var detalles:Detalles = new Detalles();
detalles.title = titleTextInput.text;
detalles.date = dateIntro.selectedDate;
detalles.photo = photoTextInput.text;
detalles.description = descriptionTextInput.text;
updateDetallesResult.token = detallesService.updateDetalles(detalles);
}
]]>
</fx:Script>
<fx:Declarations>
<valueObjects:Detalles id="detalles"/>
<detallesservice:DetallesService id="detallesService"/>
<s:CallResponder id="updateDetallesResult"/>
</fx:Declarations>
<s:actionContent>
<s:Button label="BACK" click="{navigator.popView();}"/>
</s:actionContent>
<s:Form x="70" y="68" defaultButton="{button}">
<s:FormItem label="Title">
<s:TextInput id="titleTextInput" text="@{detalles.title}"/>
</s:FormItem>
<s:FormItem width="766" label="Date">
<s:DateSpinner id="dateIntro" displayMode="date" selectedDate="@{detalles.date}"/>
</s:FormItem>
<s:FormItem label="Photo">
<s:TextInput id="photoTextInput" text="@{detalles.photo}" />
</s:FormItem>
<s:FormItem label="Description">
<s:TextInput id="descriptionTextInput" text="@{detalles.description}"/>
</s:FormItem>
<s:Button id="button" label="UpdateDetalles" click="button_clickHandler(event)"/>
</s:Form>