Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7083421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:10:32+00:00 2026-05-28T07:10:32+00:00

Hello guys. I trying set EditText to input only numbers and point ( .

  • 0

Hello guys.

I trying set EditText to input only numbers and point (” . “) that’s all. Im already using inputType.. but there numeric keyboard with “+”,”-” and “#” and without point/period (“.”)
example for what need it : 100.99 .. that’s all.
I found some code :

<EditText android:text="100.99"
android:id="@+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numeric="integer|decimal" />

but it’s in xml… i want create it by code. Also i mean this string :

 android:numeric="integer|decimal"

Please if any one know how to set this settings by code.. reply me

Regards, Peter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:10:33+00:00Added an answer on May 28, 2026 at 7:10 am

    Try using:

    mEditText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
    

    Edit :

    The suggestion i have given above was taken from Doc. but as you said it is not working properly,i can suggest you a more thing.

    Add a TextWatcher to your EditText as below,after you set above input type:

    mEditText.addTextChangedListener(new TextWatcher() {
    
        @Override
        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3){         
    
              if(arg0.length()!=0)
              {
                    String s=arg0.toString();
                    Character c=s.charAt(arg0.length()-1);
    
                    if(c=='/' || c=='\\' || c=='|' || c=='"' || c==':' || c==';' || c=='?' || c=='/' || c==',' || c=='<' || c=='>' || c=='!' || c=='@' || c=='#' || c=='$' || c=='%' || c=='^' || c=='&' || c=='*' || c=='(' || c==')' || c=='_' || c=='=' || c=='+' || c=='-')
                    {               
                        if(arg0.length()!=1)
                        {
                            String s1=s.substring(0,arg0.length()-1);
                            mEditText.setText(s1);
                            mEditText.setSelection(s1.length());    
                        }
                        else
                        {
                            mEditText.setText("");
                        }
                    }
              }     
        }               
        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {
        }               
        @Override
        public void afterTextChanged(Editable arg0) {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys. I think it isn't possible just using PHP, but just to be
Hello guys i have set background image on my input text and text area
Hello Guys! I have been trying to create a cool Image Slider using Jquery!
Hello all im trying to make this slide effect http://tinyurl.com/628z32d but im new to
hello Guys, I am trying to change to background and color of all my
Hello guys and girls im trying to a sql update but think i forgot
Hello guys i`m trying to delete a row in a access database but when
Hello guys i am trying to show all the users pokemon were the table
Hello guys i have a problem while trying to use the 'radio' input in
Hello guys first of all apologize for asking such a simple and yet redundant

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.