We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone, I'm on a project on Android where I have to input some text in Japanese (with google IME keyboard as an example), and as you probably know, I looked a lot for it on forums, and neither controlP5 TextField nor APwidgets work on Processing 3.x... So I was wondering if there was any possibility of creating a "normal" Java TextField in Processing which could normally get IME keyboard characters (I'm not Java skilled enough for that so I hope you'll be able to help me^^) Thanks forward !
Answers
https://forum.Processing.org/two/discussions/tagged/jtextfield
@olivi55=== android has classes (widgets) for that :: textView && EditTextView, with a lot of parameters (scrolling, multilines etc.)...
@akenaton thx I think I'll use that !...but as an example, how could I set this textView or EditTextView location in processing ? And since I'm currently using Ketai library to get the keyboard out, how do they manage together ? (I'm really bad for raw java :/ ) Thx forward !
@olivi55===
not any idea about ketai (i prefer to work with native android); as for the textView see the code below. Of course you can set a lot of other parameters (margin, background color and so on).
@akenaton ...wow thx...i'll try to add thi into my project monday...I'll keep you informed ^^
@akenaton Hi again, I just tried your program...It works well as TextView but when I want to put an EditText, when I tap on it, it loses focus instantly...I found this but since I don't use xml I don't know how to manage it in processing :/
@olivi55=== not sure to understand what you mean.Put your code. Normally when you touch the edit text it opens the soft keyboard input and you can use it. The way for displaying the keyboard can also be customized by code with parameters (SOFT_INPUT_STATE_ALWAYS_VISIBLE and so on)
@akenaton I just tried your code too. It launches on my phone but nothing happens in response to screen touches... ?
@hudson_m4000=== nothing happens because this is a static textView if you want more (keyboard and so on) you must change the textview for an edit text...
@akenaton @hudson_m4000 in fact the program runs, text is here, but when I touch on the EditText, it takes focus, but just after the focus is lost...as it looks it seems the focus is somehow reset in the next run of draw( )...
@olivi55===put the code you are using (mine one transformed with edit ext instance instead of textview)
@akenaton
I just took your code and replaced the TextView as an EditText
@akenaton ok ... I will fiddle around a bit more ! :)
@olivi55== no, it cannot work like this : 1) the parameters for editText and textView are of the same kind but not exactly the same! 2) as you add the textView on the runnable it takes/looses the focus and the keyboard cannot be shown...
simple snippet code::
ok thx ! I'll try to manage it with that... Thx a lot @akenaton for your patience ^^
@akenaton ... sorry something again :/...I managed to change the size of the EditText, but I can't manage to move it..I tried with setMargins, but I get a compiling error :/
@olivi55===you have to understand what happens (hidden by P5!)
So: in order to move it there are different solutions you can try: - most simple:: you add white spaces to the text you enter with setText():: a workaround!!!! - other: you change the params of the parent (fl) adding padding to it (left, top, right, bottom) as integer - other (you have created a relativeLayout for the edit text) so you can add rule to it, which allows you to put the dit text at center, left, right bottom alignment from its parent
try all of them and choose...Remember also that with the getText method you can display the entered text in a classical P5 way text("", int, int); and just before remove the edit text!!!
@akenaton thx again, I'll go on padding fl then !
@akenaton ...still problems -_- sorry :/ ...I can't manage to add a marging to the relative layout :/...isn't there another way to set an exact pixel position of the EditText relatively to its parent ?
@akenaton Line 19 of you latest sample code working with editText, is that valid Processing code? I am getting an error message:
<a href="/two/profile/Override">@Override</a>
Also for anybody running that example, you also need to include:
import android.widget.EditText;
Kf
@kfrager===
this is only a typo when you cut/copy here you have to write only:: @Override, nothing else (erase the other chars)
@akenaton, when posting code w/ annotations, add 1 space between the
@
& the annotation in order to work around the forum's code glitch. *-:)@GoToLoop====
ok && excuse me--- i ll try to remember! :)]
@akenaton hi again ! I'm trying to place my EditText by adding margins but it doesn't change anything :/...any idea on why it doesn't work ? thx forward !
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.setMargins(300,300,300,300); edit.setLayoutParams(params);
Hi @ olivi55 When you add margins, you mean that are you trying to place your editText in your canvas?
Would this work for you:
Kf
@kfrajer OMG thx finally why didn't I try this before thx a lot X)
@akenaton @kfrajer Hi ! me again, and I hope this time is the last time...in my app I have need to make my EditText
.setVisibility(View.GONE)
and able to get it back.setVisibility(View.VISIBLE)
after...but when I try it I get this error : android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. ...How can I modify this EditText visibility (or just disable it and reenable it after) easily anywhere in my program ? Thx forward again ! ^:)^@olivi55=== i have not time enough to explain exactly (code) what to do but i think (without seeing what you have written!!!) the solution is to make a runnable and call there .setVisibility()....Android is very threadSensitive!
@akenaton : just perfect thx ! I took back your Runnable syntax from one of your previous posts !...thank you a lot...now I'll now what to do for this error ! It works perfectly now !