Loading...
Logo
Processing Forum
considering that controlp5 library doesn't seem to work on android, are you aware of any possible solution for user-input field in order to setup basic user options for a processing sketch running on android? I have a client that communicates via osc messages to a remote pen plotting server. the client is a processing sketch, and I wanted the user to be able to set the server's url and port. Thanks in advance for any tip or help.
best, francesco

Replies(12)

I am making a library "APWidgets" that wraps Android widgets for Android Processing.

It so far has the widgets:
Button,
EditText,
CheckBox,
VideoView (For videofiles placed on the sdcard),
MediaPlayer (for sound files placed in the data folder),
AnalogClock.

I have released it under GPL on Google Code:

http://code.google.com/p/apwidgets/

The latest build is "APWidgets_r14.zip"



Copy code
  1. import apwidgets.*;

    PWidgetContainer widgetContainer;
    PEditText textField;

    void setup(){
     
      widgetContainer = new PWidgetContainer(this); //create new container for widgets
      textField = new PEditText(20, 100, 150, 50); //create a textfield from x- and y-pos., width and height
      widgetContainer.addWidget(textField); //place textField in container
     
    }

    void draw(){
     
      background(0); //black background
     
      text(textField.getText(), 10, 10); //display the text in the text field
    }

great work! this is going to be very useful, thanks.
I had to hack something dirty and not much functional, now I will try to rewrite it using your kindly provided efforts.
thanks again, francesco
I tested the examples form the wiki with the latest version of APWidgets (r14) on a Galaxy S (w/2.1) and a Nexus 1 (w/2.2). They run great. Nice work!
Thanks!

But weirdly it doesn't work for me, I get this error :

...\Android_SDK\android-sdk\tools\ant\main_rules.xml:384: Compile failed; see the compiler error output for details.

Yes I copied the jar file and usually extra libraries work... what else could i be missing ? ;(


@thomman:

What code are you trying to run? What OS are you on? Which version of APWidgets do you use?

I just uploaded a new compile for Java 1.5. Maybe it's broken somehow.
@ rikard:

I am using your library and it works great, thanks for this. 

I am having trouble with storing text from an input field in a variable. In processing for desktops i would use something like:
Copy code

  1. void keyPressed() {
  2.   // If the return key is pressed, save the String and clear it
  3.   if (key == '\n' ) {
  4.     address = typing;
  5.   } 
  6.   else {
  7.     // Otherwise, concatenate the String
  8.     // Each character typed by the user is added to the end of the String variable.
  9.     typing = typing + key;
  10.   }
  11. }

The keyPressed function does not seem to work on android... is that correct? 

How would  i go about in order to store user input after pressing the return key? Or should i use another button (when pressed the current string is stored)?

thanks in advance!

Hi, thanks for sharing.

I tested example as andres.colubri did, but they were not work and show error as below:
any ideas? thanks!


Exception in thread "main" java.lang.NoClassDefFoundError: android/view/View$OnClickListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at processing.core.PApplet.runSketch(PApplet.java:7259)
at processing.core.PApplet.main(PApplet.java:7445)
Caused by: java.lang.ClassNotFoundException: android.view.View$OnClickListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 19 more

Hi lei.gao

Did you perhaps forget to enable Android Mode?


Hi Rikard,

Yes. After  enable Android Mode, it works now, it looks great, thanks so much for your work and help.
(i thought is too slow to open a android emulator so i thought maybe i can try it just with Processing, that's way it didnt work before)
this is great!!! all it needs is a slider.
Hi Jorrebor.

Have a look at the advanced example for APEditText:

http://code.google.com/p/apwidgets/wiki/APEditText_Advanced_example

You can set the return button to be a "done"-button through the " setImeOptions" method. And don´t forget to setCloseImeOnDone so you can capture the event in the onClickWidget method declaration.

Best
Rikard
The library is great! Thank you.

I'm not able to solve on thing, though. The BACK and MENU keys seem to be overridden once I start editing a text field, which means the user can't go back unless they fill all the fields and click done. Any idea on how to solve this?

Cheers.