我正在开发一个黑莓应用程序, 其中包括缩微胶片功能, 但这个功能在触摸屏幕设备中起作用。 我的应用程序也会在曲线类型的设备上工作 。
请让我知道“如果装置是触摸屏或不是触摸屏,
我正在开发一个黑莓应用程序, 其中包括缩微胶片功能, 但这个功能在触摸屏幕设备中起作用。 我的应用程序也会在曲线类型的设备上工作 。
请让我知道“如果装置是触摸屏或不是触摸屏,
如果您只需要支持 OS 4.7+ 设备,就不需要使用预处理器。 您可以用这个程序测试触摸屏:
boolean isTouch = TouchScreen.isSupported();
Rupak 在他的回答中建议的内容可能不够( 只需添加触摸处理代码, 而非触摸设备将被忽略 ) 。 在您的情况中, 如果您想要支持缩放功能, 您可能需要积极检测一个非触摸设备( 上面的代码), 并选择添加一个新的缩放 < code > 按钮字段 < / code >, 这甚至没有显示在支持抓取手势的触摸设备上。 如果您不这样做, 那么非触摸设备将无法缩放, 或者触摸设备将用不必要的按钮来覆盖屏幕 。
但是, TouchScreen
API仅用于4.7+。 如果您需要对旧的OS版本也使用相同的代码, 也可以使用其他方法 :
boolean isTouch = (new Canvas(){protected void paint(Graphics graphics){}}).hasPointerEvents();
我的应用程序大多仍然支持4.5+, 它甚至无法连接到 < 强度 > compile 强度 > 的触摸处理代码。 因此, 我通常依靠这种预处理器宏来有选择地编译不同的代码。 首先, 在文件顶端 。
//#preprocess
然后,在文件的任何地方:
//#ifndef TOUCH_SCREEN
/*
//#endif
// code only for touch devices:
import net.rim.device.api.ui.TouchEvent;
//#ifndef TOUCH_SCREEN
*/
//#endif
然后为了建造我将生产用于触摸屏设备, 我添加 TOUCH_ SCREEN 预处理标记。 如果您不想担心为触摸和非触摸设备上传不同的应用程序包, 只需用 Java 代码( is Touch
) 程序检测触摸屏幕, 并使用预处理器来remove em> 代码, 无法在前4. 7 OS 版本上编译 。
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\可以\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
自BlackBerry API4.7.0以来,又增加了触摸支持。请查看TouchEvent 类文件。
所以,如果您正在为在4.7.0或以后运行的设备建立应用程序, 您不需要做任何事情。 您可以将触摸事件相关任务编码, 应用程序将同时运行在触摸和非触摸设备上。 对于非触摸设备, 与触摸事件相关的代码将不会执行 。
如果您需要支持旧设备, 那些运行量低于4.7.0的设备, 您需要使用预处理指令 。
尝试在应用程序上使用预处理指令的链接 :
Coding for Multiple Blackberry Devices - Using Preprocessor Directives in Eclipse
其他相关链接:
< a href=>"https://stackoverflow.com/ questions/1179129/precractor-directives-support-by-the-rim-compiler"> 得到RIM汇编员 支持的预处理指令
Using preprocessor directives in BlackBerry JDE plugin for eclipse?
< a href=>""http://moclibility-techtips.blogspot.com/2010/05/how-to-use- pre-precrictor- in-blakberry.html" rel=“不跟随 nofollown norefererr">_如何使用黑莓JDE 中的预处理器
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...