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

  • Home
  • SEARCH
  • 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 8843709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:17:57+00:00 2026-06-14T11:17:57+00:00

how to set only numeric value for EditTextPreference in android. I want a user

  • 0

how to set only numeric value for EditTextPreference in android.
I want a user to enter a port number not sure how can I put the limitation there

I am using this code, user can enter any string. Want to limit the user to atleast numbers only

   <EditTextPreference 
    android:defaultValue="4444" 
    android:key="port" 
    android:title="Port" 
    android:dependency="service_on"        
    />    
  • 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-06-14T11:17:59+00:00Added an answer on June 14, 2026 at 11:17 am

    EditTextPreference widgets should take the same attributes as a regular EditText, so use:

    android:inputType="number"
    

    Or more specifically use:

    android:inputType="numberDecimal"
    android:digits="0123456789"
    

    since you want to limit the input to a port number only.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can I have a data set of only time intervals (no dates) in
Does this smell? I have a few properties you can only set once. They
Using htmlentities() is there a way I can set to allow only <b> and
In Java is there an object like a Set that can contain only unique
How can i set the keyboard to open in number mode or directly open
In one textbox users are only allowed to enter numeric values less than 99.99.How
I recently encountered a scenario in which if a set only contained a single
Is it possible to only set the lower bound of a limit for continuous
The program I've written is set to only accept positive integers as input. If
I've got an old RRD file that was only set up to track 1

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.