我試圖讓我的本地sqlite數據庫顯示單擊按鈕上的下一個記錄。使用Flex實現SQLite數據庫中的「下一步」或「上一步」按鈕
我看過像Getting next record in SQLite database for mobile application這樣的帖子,但是他們的代碼爲我提供了很少的解決方案。這裏是我的代碼示例:
AS3:
private function getNext():void
{
nextRecordId = targetRecordId + 1;
selectStmt = new SQLStatement();
selectStmt.sqlConnection = conn;
var sql:String = "SELECT [Index], Title, CAST(Picture AS ByteArray) AS Picture FROM Data WHERE [Index] = 1" ;
/* selectStmt.parameters[@nextRecordId] = nextRecordId; */ // Id of next record
selectStmt.text = sql;
selectStmt.addEventListener(SQLEvent.RESULT, selectResult2);
selectStmt.addEventListener(SQLErrorEvent.ERROR, selectError2);
selectStmt.execute();
}
private function selectResult2(event:SQLEvent):void
{
selectStmt.removeEventListener(SQLEvent.RESULT, selectResult2);
selectStmt.removeEventListener(SQLErrorEvent.ERROR, selectError2);
var result2:SQLResult = selectStmt.getResult();
dataField2 = new ArrayCollection(result2.data);
dp2 = ArrayCollection(dataField);
if (result2.data != null)
{
pngIndex = result2.data[0].Index;
pngTitle = result2.data[0].Title;
pngByteArray = result2.data[0].Picture;
displayPic.source = pngByteArray;
}
}
UI MXML:
<s:Scroller interactionMode="touch"
width="640"
height="830">
<s:Group>
<s:Image id="displayPic"
x="0" y="16"
width="640"
scaleMode="stretch"
smooth="true" smoothingQuality="high"
/>
<!--<s:TextArea x="9" y="731" text="@{pngTitle}"/>-->
</s:Group>
</s:Scroller>
非常感謝您的幫助/諮詢
爲了澄清,我正在尋找如何從數據庫中調用下一條記錄,以及相應的Android「處理程序」來更新UI。謝謝! – SQLiteNoob