Android EditText retains two decimal places, androidedittext

Source: Internet
Author: User

Android EditText retains two decimal places, androidedittext

Double d = 3.1465926; String result = String. format ("%. 2f", d); System. out. println (result );


Android uses EditText as the amount input box to keep the minimum to the minute, that is, keep the two decimal places in it.

First, set android: numeric = "decimal" in the xml file, and then set the control condition % 0.2d to EditText. setoneditexceptionlistener () in the code. Get the real-time content of Edit in this time, and determine whether the content after the decimal point exceeds two lengths.
 
Can the history of the last change be retained in android EditText?

Yes. With AutoCompleteTextView, you can set the Adapter and click EditText to have the set content. This depends on how your program is written. After the user inputs, the input content is stored, save it to the database or the place you want to store it, and then start the program and take it out.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.