2

I have a preference to get port of a service as shown below

  <EditTextPreference 
    android:defaultValue="4444" 
    android:key="port" 
    android:title="Port" 
    android:dependency="service_on"  
    android:inputType="number"      
    android:maxLength="4"        
    />    

I have restricted it to maxLength 4 but there does not seem to be a minlength or minvalue ??

Basically I want to avoid empty values or lower value ports to avoid conflicts of port already in use/ android allocated ports etc

Any ideas how can I smartly changed the xml only without having to check on callbacks/listeners ?

Thanks,

Ahmed
  • 14,503
  • 22
  • 92
  • 150
  • You can't. You will need some (Java) code to parse the text and determine whether or not it's a valid port. – Cat Dec 27 '12 at 17:53
  • there is already a similar post: http://stackoverflow.com/questions/2535132/how-do-you-validate-the-format-and-values-of-edittextpreference-entered-in-andro – gezdy Dec 27 '12 at 19:23
  • @Eric can you advise what's valid range in android for ports ?? – Ahmed Dec 28 '12 at 19:56

0 Answers0