- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道两种保存/加载应用程序设置的方法:
我想知道您使用应用程序设置的做法是什么?
The persistent store provides a means for objects to persist across device resets. A persistent object consists of a key-value pair. When a persistent object is committed to the persistent store, that object's value is stored in flash memory via a deep copy. The value can then be retrieved at a later point in time via the key.
用于存储和检索设置的帮助器类示例:
class PSOptions {
private PersistentObject mStore;
private LongHashtableCollection mSettings;
private long KEY_URL = 0;
private long KEY_ENCRYPT = 1;
private long KEY_REFRESH_PERIOD = 2;
public PSOptions() {
// "AppSettings" = 0x71f1f00b95850cfeL
mStore = PersistentStore.getPersistentObject(0x71f1f00b95850cfeL);
}
public String getUrl() {
Object result = get(KEY_URL);
return (null != result) ? (String) result : null;
}
public void setUrl(String url) {
set(KEY_URL, url);
}
public boolean getEncrypt() {
Object result = get(KEY_ENCRYPT);
return (null != result) ? ((Boolean) result).booleanValue() : false;
}
public void setEncrypt(boolean encrypt) {
set(KEY_ENCRYPT, new Boolean(encrypt));
}
public int getRefreshPeriod() {
Object result = get(KEY_REFRESH_PERIOD);
return (null != result) ? ((Integer) result).intValue() : -1;
}
public void setRefreshRate(int refreshRate) {
set(KEY_REFRESH_PERIOD, new Integer(refreshRate));
}
private void set(long key, Object value) {
synchronized (mStore) {
mSettings = (LongHashtableCollection) mStore.getContents();
if (null == mSettings) {
mSettings = new LongHashtableCollection();
}
mSettings.put(key, value);
mStore.setContents(mSettings);
mStore.commit();
}
}
private Object get(long key) {
synchronized (mStore) {
mSettings = (LongHashtableCollection) mStore.getContents();
if (null != mSettings && mSettings.size() != 0) {
return mSettings.get(key);
} else {
return null;
}
}
}
}
sample app screen http://img182.imageshack.us/img182/6348/appsettings.png
使用示例:
class Scr extends MainScreen implements FieldChangeListener {
PSOptions mOptions = new PSOptions();
BasicEditField mUrl = new BasicEditField("Url:",
"http://stackoverflow.com/");
CheckboxField mEncrypt = new CheckboxField("Enable encrypt", false);
GaugeField mRefresh = new GaugeField("Refresh period", 1, 60 * 10, 10,
GaugeField.EDITABLE|FOCUSABLE);
ButtonField mLoad = new ButtonField("Load settings",
ButtonField.CONSUME_CLICK);
ButtonField mSave = new ButtonField("Save settings",
ButtonField.CONSUME_CLICK);
public Scr() {
add(mUrl);
mUrl.setChangeListener(this);
add(mEncrypt);
mEncrypt.setChangeListener(this);
add(mRefresh);
mRefresh.setChangeListener(this);
HorizontalFieldManager hfm = new HorizontalFieldManager(USE_ALL_WIDTH);
add(hfm);
hfm.add(mLoad);
mLoad.setChangeListener(this);
hfm.add(mSave);
mSave.setChangeListener(this);
loadSettings();
}
public void fieldChanged(Field field, int context) {
if (field == mLoad) {
loadSettings();
} else if (field == mSave) {
saveSettings();
}
}
private void saveSettings() {
mOptions.setUrl(mUrl.getText());
mOptions.setEncrypt(mEncrypt.getChecked());
mOptions.setRefreshRate(mRefresh.getValue());
}
private void loadSettings() {
mUrl.setText(mOptions.getUrl());
mEncrypt.setChecked(mOptions.getEncrypt());
mRefresh.setValue(mOptions.getRefreshPeriod());
}
}
最佳答案
第三个选项:使用 RMS 进行简单的应用程序设置。
虽然您建议的持久存储听起来不错,但它与任何其他 java 手机都不兼容,因此当您必须移植应用程序时,您必须重新创建这部分
我在某处读到,只有在图片或视频的情况下才应该在文件系统本身上创建文件,因此基本上用户也可以以另一种方式查看内容。
关于黑莓 - 应用程序设置保存/加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1476994/
我想创建后台应用程序,它将监听哪些应用程序已启动以及哪些应用程序移至前台。 请回复 如果问题不清楚会再次解释。 谢谢 最佳答案 这是你可以做的: 使用 ApplicationManager.getFo
下午好。 我开始用 java 和 blackberry 编程。 我正在开发一个带有三个窗口的应用程序,我将显示有关设备的基本信息,这些窗口已经完成并可以工作。 我需要创建一个在后台运行的进程,这个进程
如何翻转 Bitmap上下翻转? (我需要这个来在另一个程序中加载 OpenGL 纹理)。 这是我失败的尝试: stripe.png(由 Pitr@OpenClipart 提供): 翻转.java:
从 Internet 上可用于签署 BB 应用程序的内容来看,我可以猜测我们只需要用于签署应用程序的 .cod 文件,而不需要源代码。 有人可以确认这一点吗? 最佳答案 编译代码时会自动生成 .cod
我想访问闹钟。在我的应用程序中,我已成功访问日历并设置了约会,但我如何访问闹钟。请帮我。以下是我的代码 public class Alarm { private Event event;
作为应用程序的一部分,我们将在设备上的“file:///store/home/user/”位置创建一个文件 myApp.cfg。设备上的加密已启用。因此,myApp.cfg 被重命名为 myApp.c
我需要制作一个包含可点击号码的标签,这样当用户点击标签时,就会调用电话号码(或向用户显示调用电话的选项)。当我现在点击标签时,我只得到一个工具提示类型的菜单,其中包含复制数字的选项... privat
我有兴趣在我的 BlackBerry 应用程序中添加一个可拖动的 slider 。 我想知道 BlackBerry API 中是否有类似的东西,或者是否有人做过类似的东西! 最佳答案 有一个Gauge
最初开发黑莓应用的时候,并没有太在意能够支持多种屏幕分辨率。所以,我最终得到了在 320*240 分辨率下运行良好但在其他屏幕上完全困惑的代码。 我该如何解决这个问题?或者一般来说,如果不为每个资源构
我创建了一个这样的静态函数。 public static Bitmap Bitmap(String path) { Bitmap bitmap = Bitmap .ge
我需要 BlackBerry 本地化方面的帮助。我在 http://na.blackberry.com/eng/developers/resources/developer_labs.jsp#tab_
我创建了一个 RichTextField 我想让它只允许整数值。我怎样才能做到这一点? 最佳答案 你可以尝试这样的事情: public class MyRichTextField extends Ri
在 BlackBerry 平台中,我想知道是否可以/如何执行以下操作: 检索通话记录(我对来电记录特别感兴趣); 删除特定的通话记录; 最佳答案 要检索电话日志,请查看 PhoneCallLog cl
我想知道我们是否可以调整图像大小。假设我们要在黑莓屏幕上绘制一个实际尺寸为200x200且尺寸为100 x 100的图像。 谢谢 最佳答案 只是一种选择: BlackBerry - draw imag
黑莓 JDE 不包括 java.util.ArrayList ,即使它知道 java.util ?那是怎么回事? BB 有对应的类(class)吗?我不想使用数组,真的,因为我要处理的对象数量未知。为
我想使用 graphics.drawLine 方法在 drawListRow 中的黑莓 Listfield 中添加一个分隔符,但下面根本没有绘制线是我正在使用的来源 drawListRow(ListF
我正在为Blackberry设备开发一个应用程序。这个程序包含一个数据库。由于该API是在最新的API版本上提供的,因此我决定使用SQLite。 我遵循了随处都可以找到的所有示例,但是无论发生什么情况
我已将 Blackberry 4.6.0 应用程序移植到 4.7.0 上的 Storm。除了我试图控制的触摸事件之外,一切都运行良好。我在下面的方法中捕获触摸事件,它按预期执行,但问题是在我的 tou
我正在为 BB 开发一个项目。该应用程序与网络一起工作,并通过 HTTP 发送/接收数据。现在我使用队列和队列管理器。管理器从一个后台线程开始,并在 while (true) 循环中工作,检查队列中是
我想在黑莓中合并两个图像。一张图像是大图像,另一张图像是小图像。小图像的位置将由开发人员定义。有哪些可能的方法? 最佳答案 您可以使用 Graphics 类以不同的偏移量在其上绘制多个位图。查看Gra
我是一名优秀的程序员,十分优秀!