I have a "number edittext". I want to limit the entry of the "number edittext" to 10 million. How can I implement this?
you can set limit in Edit Text for this purpose. try following code
android:maxLength="9"
This will allow you to add number upto 999999999 Rs.
Limit text length of EditText in Android
I am not sure what you mean exactly but i am guessing you don't want the text box size to be more than 1 and 7 zeros, i think the above link should help you if that's the case.
Related
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 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 :)!
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!
I am trying to fit an EditText into different ImageView templates. For each template, I want to restrict the EditText to a specific width.
For example, in one of my templates, the EditText field should fit a maximum of 300 pixels wide, so I would like to set the text width limit to 300 pixels.
However, I cannot restrict the length by character length because, typing:
"iiiiiii" is not the same width as "wwwwwwwwww."
Would anyone happen to have a solution to this? Thanks.
You could use a textWatcher. This would have a method called onTextChanged(). You could override this to get the length. Once this is done, you could alter the length of the textView itself.
http://www.rqna.net/qna/tssiw-android-edittext-limit-string-length-not-by-characters.html
That guy answered your question with probably the best answer 2 months ago...
You can achieve something similar with android:paddingRight through xml
I have items with a lot of text, mostly around 8500 to 9500 characters.
I want to display that in a scrollable textview, but when put the text in a TextView, it seems to be truncated to a max of 9000 characters, while a (the original) String object can hold more. Is there a way to extend this number? Absolutely no parameters on restricting the size of the TextView has been set.
Thanks in advance.
Here is a link which basically says:
The answer is "how much memory can you allocate?" Of course the
system needs to allocate resources to measure and typeset and render
all of that text. If it's too long, consider showing the text in
pages or chunks.
So if your string has 50000 characters, show it in 9000 character chunks.
Use this on your EditText or TextView:
android:maxLength="1000000"
Some phones have an hard limit of 9000 chars by default.
For anyone looking at this in 2018, I don't think there's a hard limit. I have a pretty cheap Android phone with 1 GB of RAM and was able to both edit and display over 40,000 characters of text. There is a slight initial pause when pasting into the edit box and when rendering into a text view but otherwise it works just fine.