I defined a EditText in XML with attribute android:inputType=”numberSigned”, so, when I try to get it in Java Code like:
int type = mEditText.getInputType();
switch(type){
case InputType.TYPE_NUMBER_FLAG_SIGNED:
//do when I get EditText defined with 'numberSinged'
//do something
break;
}
But, It doesn’t work for me. So I try to check Android source code, TYPE_NUMBER_FLAG_SIGNED=4096. When I try to print println(mEditText.getInputType()),it turns to be 4098. And I can’t find any variable equals 4098.
Can anybody tell me the reason?
I’m not good at English, may you can understand me! Thanks!
there can be multiple flags assigned to inputType. To find out if a flag is set or not, use the bitwise AND (
&) operator:I guess, the usage of
switchcase is not possible here.