我正在使用XMADL编写跨平台移动应用。我在本地数据库中有一个表'user',其中包含firstname,lastname,email,pwd列。如何在调用userprofile屏幕时显示数据? 配置文件屏幕定义为
<controls>
<control name="labelfirstname" type="TEXT" x="2" y="3" width="30" height="8"
appearance_name="black" data_type="VARCHAR"
default_value="First Name"/>
<control name="editfirstname" type="EDIT" x="35" y="2" width="50" height="8"
appearance_name="edit_box" data_type="VARCHAR" field_name="firstname"
default_value="" size="80"/>
<control name="labellastname" type="TEXT" x="2" y="12" width="30" height="8"
appearance_name="black" data_type="VARCHAR"
default_value="Last Name"/>
<control name="editlastname" type="EDIT" x="35" y="12" width="50" height="8"
appearance_name="edit_box" data_type="VARCHAR" field_name="lastname"
default_value="" size="80"/>
<control name="labelemail" type="TEXT" x="2" y="22" width="30" height="8"
appearance_name="black" data_type="VARCHAR"
default_value="Email"/>
<control name="editemail" type="TEXT" x="35" y="22" width="50" height="8"
appearance_name="black" data_type="VARCHAR" field_name="email"
default_value="" size="80"/>
<control name="labelpassword" type="TEXT" x="2" y="32" width="30" height="8"
appearance_name="black" data_type="VARCHAR"
default_value="Password"/>
<control name="editpassword" type="PASSWORD" x="35" y="32" width="50" height="8"
appearance_name="edit_box" word_wrap="0" data_type="VARCHAR" field_name="password"
default_value="" size="80"/>
</controls>
</screen>
答案 0 :(得分:1)
您可以通过定义screen attribute“local_data_source = sql query”从本地数据库中获取数据并显示在屏幕上。
用下面的代码替换你的元素。
<screen name="userprofile" screen_type="SCREEN" allow_reorientation="true" allowed_layouts="BOTH" scroll="VERTICAL"
width="100" height="100" local_data_source="select lastname, firstname, email, password from user_details where email='<email>'">
查询结果将是column_name / value对。如果数据表的column_name与控件的field_name匹配,则将为该值分配该值。
一旦调用了屏幕,数据将从数据库中获取,并通过field_name firstname,lastname,email和pwd提供给控件。