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 6575529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:23:53+00:00 2026-05-25T15:23:53+00:00

I have EditText field with android:numeric=decimal and android:inputType=phone for entering decimal numbers. I use

  • 0

I have EditText field with android:numeric=”decimal” and android:inputType=”phone” for entering decimal numbers. I use input type phone because it is more easy to user enter numbers.

For any device with soft keyboard I haven’t any problem but when I begin use hard keyboard when will print wrong numbers (for example when I use HTC Desire Z).

How to solve this problem?

P.S. I developed the “Simple Loan Calculator” for Android – it’s opensource and freeware

  • 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-25T15:23:54+00:00Added an answer on May 25, 2026 at 3:23 pm

    Solved!

    AndroidManifest.xml

    <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation|keyboard" >
    

    MainActivity.java

    public void onCreate(Bundle savedInstanceState) {
        ....
        setPriceInputFilter(amountEdit, interestEdit, fixedPaymentEdit, periodYearEdit, periodMonthEdit, downPaymentEdit, disposableCommissionEdit, monthlyCommissionEdit);
        ....
    }
    private void setPriceInputFilter(EditText ... fields){
      PriceInputFilter filter = new PriceInputFilter();
      for (EditText field: fields){
        field.setFilters(new InputFilter[]{filter});
      }
    }
    public void onConfigurationChanged(Configuration newConfig) {
        if(newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO){
           setInputType(InputType.TYPE_NULL, amountEdit, interestEdit, fixedPaymentEdit, periodYearEdit, 
                                             periodMonthEdit, downPaymentEdit, disposableCommissionEdit, monthlyCommissionEdit);
           Toast.makeText(this, "HARD-keyboard", Toast.LENGTH_SHORT).show();
        }else{
          setInputType(InputType.TYPE_CLASS_PHONE, amountEdit, interestEdit, fixedPaymentEdit, periodYearEdit, 
                                                   periodMonthEdit, downPaymentEdit, disposableCommissionEdit, monthlyCommissionEdit);
          Toast.makeText(this, "SOFT-keyboard", Toast.LENGTH_SHORT).show();
        }
        super.onConfigurationChanged(newConfig);
    }
    private void setInputType(int type , EditText ... fields){
        for (EditText field: fields){
          field.setInputType(type);
        }
    }
    

    PriceInputFilter.java

    public class PriceInputFilter implements InputFilter {
      public CharSequence filter(CharSequence source, int start, int end,  Spanned dest, int dstart, int dend) {
        String checkedText = dest.toString() + source.toString();
        String pattern = getPattern();
        if (!Pattern.matches(pattern, checkedText)) {
          return "";
        }
        return null;
      }
      private String getPattern() {
        return "[0-9]+([.]{1}||[.]{1}[0-9]{1,2})?";
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whenever I have an EditText field in my android application, it is highlighted with
Is it possible to have Android's numeric keypad display for an EditText (the one
I have an activity with one EditText where I need to input numbers only.
I have an activity that contains several user editable items (an EditText field, RatingBar,
To use as an example: lets say that I have 2 EditText s and
I have an Activity in Android, with two elements: EditText ListView When my Activity
I have an Edit Text that is defined as follows. <EditText android:layout_width=fill_parent android:layout_height=wrap_content android:maxLines=1
If you own Android phone you are no doubt have noticed how in the
So I have a simple Edit-text with number input. User enters his phone number
I have this EditText field inside of one activity, and I want it so

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.