9.22 任务 找到解决输入 格式的问题

1.是针对软键盘 的弹出

 

 android:inputType="textEmailAddress"

 

2.对输入的限制

静态设置

 

android:digits="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@._"

http://www.eoeandroid.com/thread-3542-1-1.html

 

3.动态设置

http://apps.hi.baidu.com/share/detail/44746167

android的输入界面中,有些输入框只能输入数字(比如电话号码),有些只能输入字母(比如英文名),有些既能包含字母又能包含数字(比如email address),还有其他的特殊限制,如果我们要做这些限制的话,就要用到InputType的设定,下面将列举出常用的类型:

用法:((EditText)findViewById(R.id.editview)).setInputType(InputType.*);  

InputType的类型:

int TYPE_CLASS_DATETIME Class for dates and times.  

int TYPE_CLASS_NUMBER Class for numeric text.  

int TYPE_CLASS_PHONE Class for a phone number.  

int TYPE_CLASS_TEXT Class for normal text.  

int TYPE_DATETIME_VARIATION_DATE Default variation of TYPE_CLASS_DATETIME: allows entering only a date.  

int TYPE_DATETIME_VARIATION_NORMAL Default variation of TYPE_CLASS_DATETIME: allows entering both a date and time.

int TYPE_DATETIME_VARIATION_TIME Default variation of TYPE_CLASS_DATETIME: allows entering only a time.

int TYPE_MASK_CLASS Mask of bits that determine the overall class of text being given.  

int TYPE_MASK_FLAGS Mask of bits that provide addition bit flags of options.  

int TYPE_MASK_VARIATION Mask of bits that determine the variation of the base content class.  

int TYPE_NULL Special content type for when no explicit type has been specified.  

int TYPE_NUMBER_FLAG_DECIMAL Flag of TYPE_CLASS_NUMBER: the number is decimal, allowing a decimal point to provide fractional values.  

int TYPE_NUMBER_FLAG_SIGNED Flag of TYPE_CLASS_NUMBER: the number is signed, allowing a positive or negative sign at the start.  

int TYPE_TEXT_FLAG_AUTO_COMPLETE Flag for TYPE_CLASS_TEXT: the text editor is performing auto-completion of the text being entered based on its own semantics, which it will present to the user as they type.  

int TYPE_TEXT_FLAG_AUTO_CORRECT Flag for TYPE_CLASS_TEXT: the user is entering free-form text that should have auto-correction applied to it.  

int TYPE_TEXT_FLAG_CAP_CHARACTERS Flag for TYPE_CLASS_TEXT: capitalize all characters.  

int TYPE_TEXT_FLAG_CAP_SENTENCES Flag for TYPE_CLASS_TEXT: capitalize first character of each sentence.  

int TYPE_TEXT_FLAG_CAP_WORDS Flag for TYPE_CLASS_TEXT: capitalize first character of all words.  

int TYPE_TEXT_FLAG_IME_MULTI_LINE Flag for TYPE_CLASS_TEXT: the regular text view associated with this should not be multi-line, but when a fullscreen input method is providing text it should use multiple lines if it can.  

int TYPE_TEXT_FLAG_MULTI_LINE Flag for TYPE_CLASS_TEXT: multiple lines of text can be entered into the field.  

int TYPE_TEXT_FLAG_NO_SUGGESTIONS Flag for TYPE_CLASS_TEXT: the input method does not need to display any dictionary-based candidates.  

int TYPE_TEXT_VARIATION_EMAIL_ADDRESS Variation of TYPE_CLASS_TEXT: entering an e-mail address.  

int TYPE_TEXT_VARIATION_EMAIL_SUBJECT Variation of TYPE_CLASS_TEXT: entering the subject line of an e-mail.  

int TYPE_TEXT_VARIATION_FILTER Variation of TYPE_CLASS_TEXT: entering text to filter contents of a list etc.  

int TYPE_TEXT_VARIATION_LONG_MESSAGE Variation of TYPE_CLASS_TEXT: entering the content of a long, possibly formal message such as the body of an e-mail.  

int TYPE_TEXT_VARIATION_NORMAL Default variation of TYPE_CLASS_TEXT: plain old normal text.  

int TYPE_TEXT_VARIATION_PASSWORD Variation of TYPE_CLASS_TEXT: entering a password.  

int TYPE_TEXT_VARIATION_PERSON_NAME Variation of TYPE_CLASS_TEXT: entering the name of a person.  

int TYPE_TEXT_VARIATION_PHONETIC Variation of TYPE_CLASS_TEXT: entering text for phonetic pronunciation, such as a phonetic name field in contacts.  

int TYPE_TEXT_VARIATION_POSTAL_ADDRESS Variation of TYPE_CLASS_TEXT: entering a postal mailing address.  

int TYPE_TEXT_VARIATION_SHORT_MESSAGE Variation of TYPE_CLASS_TEXT: entering a short, possibly informal message such as an instant message or a text message.  

int TYPE_TEXT_VARIATION_URI Variation of TYPE_CLASS_TEXT: entering a URI.  

int TYPE_TEXT_VARIATION_VISIBLE_PASSWORD Variation of TYPE_CLASS_TEXT: entering a password, which should be visible to the user.  

int TYPE_TEXT_VARIATION_WEB_EDIT_TEXT Variation of TYPE_CLASS_TEXT: entering text inside of a web form.

 

 

9.26

 

public void afterTextChanged(Editable s) {
    for(int i=start2;i<start2+count2;i++){
     
     char c=s.charAt(i);
     
     if(!format.contains(String.valueOf(c))){
      
      s.delete(i, i+1);
      Toast.makeText(MyCardModifyPage.this.mainActivity, "Error letter", Toast.LENGTH_SHORT).show();
     }
     
     
    }
    
    
  
       }
       
   };
   
   gtalkEditText.addTextChangedListener(mTextWatcher);
   
   /*
   
    for(int i=0;i<s.length()&&s.length()>0;i++){
         
       char c=s.charAt(i);
       String format="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@._";
       
       if(!format.contains(new String(c+""))){
        s.delete(i, i+1);
        Toast.makeText(MyCardModifyPage.this.mainActivity, "Error letter", Toast.LENGTH_SHORT).show();
       }
       
      }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值