BlackBerry 应用程序开发者指南 第二卷:高级--第4章 增加设备选项 |
| 作者:佚名 来源:本站整理 发布时间:2008-3-15 0:38:53 |
|
// Add fields to the screen. public void populateMainScreen(MainScreen screen) { int index = _data.getSelected(); String[] choices = {“High”, “Low”, “None”}; _ocf = new ObjectChoiceField(“Security: “, choices, index); screen.add(_ocf); } // Save the data. public void save() { _data.setSelected(_ocf.getSelectedIndex()); _data.commit(); } // Retrieve the data. Used by other applications to access options data. public OptionsDemoData getData() { return _data; } // Inner class to store selected option values. public static final class OptionsDemoData implements Persistable { private static final long ID = 0x6af0b5eb44dc5164L; private int _selectedOption; private OptionsDemoData() { } public int getSelected() { return _selectedOption; } public void setSelected(int index) { _selectedOption = index; } public void commit() { PersistentObject.commit(this); } private static OptionsDemoData load() { PersistentObject persist = PersistentStore.getPersistentObject( OptionsDemoData.ID ); OptionsDemoData contents = (OptionsDemoData)persist.getContents(); synchronized( persist ) { if( contents == null ) { contents = new OptionsDemoData(); persist.setContents( contents ); persist.commit(); } } return contents; } } } 作者:Confach 发表于2006-04-28 22:18 pm |
| [] [返回上一页] [打 印] |
文章评论 |
