Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Java Persistence with Spring Data and Hibernate
this week in the
Spring
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Tim Cooke
Paul Clapham
Liutauras Vilda
Sheriffs:
Junilu Lacar
Rob Spoor
Jeanne Boyarsky
Saloon Keepers:
Stephan van Hulst
Carey Brown
Tim Holloway
Piet Souris
Bartenders:
Forum:
Android
Can someone explain this code?
ian bilgaen
Ranch Hand
Posts: 36
posted 5 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
et.setFilters(new InputFilter[]{ new DigitsKeyListener(Boolean.FALSE, Boolean.TRUE) { int beforeDecimal = 5, afterDecimal = 5; @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { String temp = et.getText() + source.toString(); if (temp.equals(".")) { return "0."; } else if (temp.toString().indexOf(".") == -1) { if (temp.length() > beforeDecimal) { return ""; } } else { // temp = temp.substring(temp.indexOf(".") + 1); if (temp.length() > afterDecimal) { return ""; } } return super.filter(source, start, end, dest, dstart, dend); } } });
This is an inputfilter which allows 5 numbers before and after a dot.
I understand pretty much everything except for:
-where it says that there can only be 1 dot to be set.
- what source.toString() means in
String temp = et.getText() + source.toString();
Norm Radder
Rancher
Posts: 4936
38
posted 5 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
what source.toString() means
That code calls the toString() method for the class that source is an instance of. The API
doc
says it returns a
String
.
What's that smell? Hey, sniff this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Java grid colouring in game
String tokenizer
function Numeric_data
client hangs after getting data from server
Multiline Tooltip
More...