I would put in this code a control on EditText so that it only accepts hexadecimal numbers. How do I go about doing this?
bin = (EditText)findViewById(R.id.editText02);
hex = (EditText)findViewById(R.id.editText3);
dec = (EditText)findViewById(R.id.editText1);
oct = (EditText)findViewById(R.id.editText04);
In your android layout XML file add the following attributes to EditText:
The first attribute allows only input with these numerals. Any other input is rejected and not displayed. The second attribute capitalizes characters.
credit goes to this blog post: http://mobile.antonio081014.com/2012/04/how-to-let-input-of-edittext-only-be.html
There are two options, one is described by Muhammad Annaqeeb using the properties:
other option would be using an InputFilter and REGEX to allow only hexadecimal characters:
both options have as a result:
Check this related answer too:
https://es.stackoverflow.com/a/211240/95
TextWatcher is also good option, however I prefer using custom filters. thereby, simpler way is to use InputFilter and take control of every char on the fly, see example below, hope this helps