简体   繁体   中英

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. Here to set the font color I cannot use android.graphics.Color because the method required java.awt.Color as the parameter.

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

I added JRE System Library in Java Build path. 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. You cannot use this library directly. Android uses a completely different technology to create UI elements.

You can get the necessary code from the dead project Harmony, then change the package name and refractor the project you are porting.

This solution assumes you are porting and recompiling the project that requires the awt classes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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