开发者

How to restrict Single Quote in android EditText?

friends,

i want to restrict " character 开发者_Python百科in android EditText any one guide me how to achieve this in java code?


You probably want to set an InputFilter on your EditText object

This page has an example of an InputFilter for numeric values


((EditText)findViewById(R.id.EditText01)).addTextChangedListener(new TextWatcher() 
 {           
public void beforeTextChanged(CharSequence s, int start, int count, int after) 
{             
                    //check here if character is '"' if yes don't allow to right
}          
public void onTextChanged(CharSequence s, int start, int before,  int count) 
{            

}            
@Override        
 public void afterTextChanged(Editable s)
 {             
    // TODO Auto-generated method stub         
 }     
});


May this solve it?
How to restrict special characters from an Android EditText field?


use the onKeyDown or onTextChanged event

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜