I want to Show numbers that should increase to a particular limit dynamically.
For Example if I get a number 103. Than my textView should show 1 first and than let us say 3 than 6 than similarly increasing to 103 finally. People call it lottery style text display.
Let us say number is in num variable. than numbers should increase from (num-num) to num.
I designed Logics but if number is very large say 1 billion. than increasing/lottery effect takes too much time.
I am looking for an API where I can specify time in which I want the lottery effect to finish and final number that should be there. i guess this clarifies API requirement..
Do we have any API to do it in TextView in android???
You can create simple yet random number logic for it.
Create an array say of size 10 with random numbers eg 1,13,6,8,3,15..
Create random number class that will give you random number between 0 to array length
So you will get any random number within array each time
Create addition variable, which will get incremented with the above number
before showing the number, check if its larger than the original number
if lesser, show the number, if larger, show the original number
You can implement any other logic, but I have sued this logic, so suggested it :)!
Related
I can increase the value in firebase using this simple line of code:
dbRef.child("points").setValue(ServerValue.increment(1));
Or decrease:
dbRef.child("points").setValue(ServerValue.increment(-1));
This works very well, but now I want to increase by a random percentage like by 30%. What I mean is for example in Firebase there is a value of 100, and I want to increase that by 30%, to get 130 points. Instead of pushing the actual number I want to push 30%.
What I have tried is:
dbRef.child("points").setValue(ServerValue.increment(*1.30));
And I am getting error:
Expression expected.
How can I solve this?
ServerValue.increment can only modify a value by the exact amount you specify. It can't do relative amounts. What you will have to do is read the child value, compute the final value in your code, and write the new value back.
How to find out text length containing emojis with normal text. I want to limit Edittext for maximum 20 characters. But when I add a new stylish emoji, text length reaches it's limit or sometimes it exceeds.
So I want to count 1 for a emoji. Please let me know if you have idea.
The way I would approach this would be to scan the user input using a TextWatcher and compare against a known list of emoji UTF characters counting a matched set as one character. Here's a list to get you started (I don't know how up to date it is though) https://apps.timwhitlock.info/emoji/tables/unicode
I have a scenario where I have to show a huge report which consists of about 16 fields, and the last field consists of a radio group. I've taken a Table layout for this. But the problem is, I don't know the size of each field. I mean, there could be 50 characters in one, and 2 in another, and I have to adjust the width and height basing on that without loosing the look and feel criteria. For example,the first column is a Serial No which may contain 4 digits max, the second column contains an ID which may be a 20 digit number and so on. I can use Wrap Content, but its making the page clumsy! So, my question is, is there any possibility that my fields can automatically set their width and height basing on the length of the characters.Thanks in advance! Any help will be appreciated!
This is tricky.
I have a number made of 2 digits which I load from the server. While the loading is made I want to show an animation which acts like this:
have 2 rows for 0-9 digits which spin independent
when the value is returned from the server, let's say 17, first row spins to 1 and the other until 7.
I try to illustrate this bellow in an image but not sure how good I am at doing it.
Any ideas on how to implement this ?If it takes more time for the number to come from the server, the spinning needs to repeat from 0 to 9 over and over again.
I want to find the line's first and last word of a paragraph.
sample :
My country is Turkey.I love my country very much.
There are four season in my country in a year. Each
one has 3 month. That's the place where every one
live *in*.
In such a paragraph, I want the words that is in Bold.This paragraph is in textview
and the code must take care of the width of textview.If width changes, first and last words also changes, and algorithm must find them.
If you help, I'll be glad.
I'm not sure how android handles the actual placement of text with resizes and all that. I really doubt that it adds in tab carriages and newlines to the text to display them, but if it does, you could use regex to find that. Or regex with the line anchors. Take a look at this, see if it helps:
http://www.regular-expressions.info/anchors.html