convert string to Chips in a textField - java

I want to convert text which is in a EditText to chips
There are a lot of libraries for and related question to it like this , this and this question. All of them are hard to understand (at least for me ), because all of those library have features I am not interested in.
I want to convert a text to chips which is entered into an EditText (programmatically). Is there a straight forward way to do it?
P.s. by saying Straight Forward i meant i dont want this auto completion , suggestions and the text that am entering is entered programmatically not manually

Related

Adding emoji reaction by unicode not working

Currently, I am making a music discord bot and I want it to display the list of songs it is currently playing.
The user should be able to interact with the list by moving to each page with a left arrow and right arrow emoji.
The problem is that, when I try to react to the message via a unicode, it does not seems to work as follows:
message.addReaction("U+2B05").queue();
message.addReaction("U+2B07").queue();
it throws an error saying that the Emoji is not found during runtime, even though that is the respective unicode for the emoji I wanted to sent.
I have tried to use 2B05 or Left Arrow in the string and it does not work too.
Encountered the same issue before, though one of the answers from this question helped me.
Specifically, one of the answer was:
I understood how to do it. Just need to add this line
e.getChannel().sendMessage(embedBuilder.build()).complete().addReaction("✔").queue();
Apparently adding the emoji directly into the string works.
Do this instead:
message.addReaction("➡").queue();
message.addReaction("⬅").queue();

Create text modification system like the answerfield on stackoverflow

In my android app, I want to create a text field with a lot of modification options (strong text, emphasized text, enter code here, enter link description here) like on stackoverflow.
I thought about this option:
In the answerfield of stackoverflow, strong texts are wrapped in "** **" and emphasized texts in "* *".
So I could conclude that every modification option have different special characters.
In the answer editor the special characters (**, *) are visible, so the special characters are inserted in the stackoverflow database.
So the only possibility is, that the text is interpreted after receiving it from database.
Is my guess right?
Can one of you give me a little bit android code of such a text modifier, so that I know how to start?
Just iterate About the Content in the textField and if you find a construct like ** then replace the following with a String in the whished font.

Libgdx native TextInput limit text Length

I am writing a game using Libgdx. I used what was suggested here to handle virtual keyboard when user enters player names. This actually works like a charm. However if user enters more than 8 characters in a name field, it breaks the UI design of my game. So I want to prevent user from entering more than 8 characters.
TextField has a setMaxLength method as defined here. If I set this value to 8, no matter what user enters, the first 8 characters are put in my text field. But this is kind of annoying and misleading because user can still enter, let's say 20 characters without having a clue that the only first 8 will be used.
So, my question is whether there is a mechanism to stop user entering more than 8 characters even if I use "native" way of handling TextField inputs.
Thanks in advance.
I tested this just before typing to you, so I know it works. The below code will make it so your textfield will only allow for you to enter in 8 characters into the TextField widget. Be careful though, some characters are larger (in length) than others ( chars like - are short ).
textField.setMaxLength(8); // Maximum chars will be 8
textField.setAlignment(1); // If you wanted to center the text
// (1 = Center, 2 = Right Align)
On another note, if you are adding the TextField to a table, you can change the visible width of the widget.
table.add(textField).width(50); // I believe this is in pixels
You didn't really give me much to go off from (no code), so I hope this answer helps you out.
Best of luck with your game!

Android - Formatting text (textView vs button)

I'll try to keep it simple, but it's two part.
In my Android app, I have a textview anf 4 buttons (question and 4 answers). I'm attempting to utilize the html <sub>subscript</sub> and <sup>superscript</sup>. It's working on the textivew (ie. the text is formatted the way I want it to be), but when I try to do the same thing on the buttons in the exact same way, it doesn't format them. X2 just becomes "X2" without superscript.
Why is this the case and how can I get it to work on the buttons like it works on the textview?
If it helps, I noticed something. If I pull the same string to the textview and to the buttons (keep in mind I'm pulling the strings from a variable set in a java structure I made... questions/answers I coded into arrays), the textview will read "Question # 1" and the button will read "QUESTION # 1". So, somehow the button is formatting the text and I wasn't aware of that. Could this be the reason the <sub> html code isn't working on the buttons? What's causing this and how can I fix it?
Thank you.

Java GUI input text box

I'm designing a program simulating a vending machine. You know how vending machines have that one large text box that displays whatever messages you need to know...that's what I want to do. So basically, if the user clicks a button and if the item is out of store, expired, they don't have enough credit, whatever, the message should be displayed in this box.
Then, after a second or 2, return to displaying how much money the user put into the machine. I also want to make the box so that, well theres a button next to the text box to click to insert money. When they click that, I want to make the text box editable, they then enter the amount of money they want to enter, then press insert again, and the money is inserted. The text box becomes uneditable again, and displays the credit they have in the machine.
Does anyone have any suggestions as to how to do this?
I also was wondering how I could implement the delay before getting rid of the message and returning to displaying the credit in the machine. Thank you.
As Andrew Thompson says, you would use a JTextField. Set the desired text using the setText() method and you could then use a sleep function (usleep() I think should work for your application) and then set the text again back to the Dollar value.
Edit: didn't see the last half. To enable and disable the textfield entirely, use setEnabled(true/false), to stop it from being editable, use setEditable(true/false)
Also, just thinking, you could get the current date in a timestamp format and then enter a loop where you continually get the timestamp and compare it to the first one. If the desired difference is reached then exit the loop and update the textfield. Have a look at the Java doc for Date ;)

Categories