I am new to android and learning java. In recent guide, i came across the method to toggle password field to normal text field.
Can someone please explain use of |
in this statement ?
final EditText input = (EditText) findViewById(R.id.etCommands);
if(passTog.isChecked())
{
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}else {
input.setInputType(InputType.TYPE_CLASS_TEXT);
}
Any help regarding this will be much appreciated. Thanks in advance.
Edit:
I need to know how this Bitwise OR is working infact here ? Here is complete code to avoid ambiguity regarding the variables:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.text);
Button checkCommand = (Button)findViewById(R.id.bResults);
final ToggleButton passTog = (ToggleButton) findViewById(R.id.tbPassword);
final EditText input = (EditText) findViewById(R.id.etCommands);
TextView display = (TextView) findViewById(R.id.tvResults);
passTog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(passTog.isChecked()){
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}else {
input.setInputType(InputType.TYPE_CLASS_TEXT);
}
}
});
}