2013-04-30 46 views
1

我正在使用XMADL編寫跨平臺移動應用程序。我有本地數據庫中的一個表「用戶」,列firstname,lastname,email,pwd。如何在調用userprofile屏幕時顯示數據? 輪廓屏幕通過定義screen attribute「local_data_source = SQL查詢定義爲XMADL - 從本地數據庫獲取數據

<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> 

回答

1

可以從本地數據庫和顯示在屏幕上獲取數據」。

用下面的代碼替換你的元素。

<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=&apos;&lt;email&gt;&apos;"> 

查詢結果將是column_name/value對。如果數據表的column_name與控件的field_name匹配,則該值將被分配給控件。

調用屏幕後,將從數據庫中提取數據,並使用field_name firstname,lastname,email和pwd顯示控件。