简体   繁体   English

java.awt.Color在Android中使用

[英]java.awt.Color use in Android

For my android application I need to develop a text to PDF converter and I used XSPDF ( http://code.google.com/p/xspdf/ ) for it. 对于我的Android应用程序,我需要开发一个文本到PDF转换器,我使用XSPDF( http://code.google.com/p/xspdf/ )。 Here to set the font color I cannot use android.graphics.Color because the method required java.awt.Color as the parameter. 这里设置字体颜色我不能使用android.graphics.Color,因为该方法需要java.awt.Color作为参数。

XSPDF xspdf=new XSPDF();
xspdf.setFont(XSFontType.Symbol, 72);
xspdf.setTextFillColor(Color.BLUE);

I added JRE System Library in Java Build path. 我在Java Build路径中添加了JRE System Library。 but I got FATAL EXCEPTION: 但我得到了致命的异常:

01-17 10:41:41.398: E/AndroidRuntime(26655): Caused by: java.lang.NoClassDefFoundError: java.awt.Color
01-17 10:41:41.398: E/AndroidRuntime(26655):    at com.packenius.library.xspdf.XSPDF.<init>(Unknown Source)

Do anyone know solution for this problem? 有谁知道这个问题的解决方案?

The whole java.awt.* is not part of Android. 整个java.awt.*不是Android的一部分。 You cannot use this library directly. 您不能直接使用此库。 Android uses a completely different technology to create UI elements. Android使用完全不同的技术来创建UI元素。

You can get the necessary code from the dead project Harmony, then change the package name and refractor the project you are porting. 您可以从死项目Harmony中获取必要的代码,然后更改包名称并折射您正在移植的项目。

This solution assumes you are porting and recompiling the project that requires the awt classes. 此解决方案假定您正在移植和重新编译需要awt类的项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM