So it is an EditText
. You can use the attiribute android:maxLength
to limit the number of characters as shown here https://stackoverflow.com/a/3285421/655987
Another option is to let the user to enter whatever he/she wants and then do the check background.
You can do that inside your OnClickListener
. If you want to check the value only when user clicks the positive button -which usually is the case-, then you should do it as follows:
...
.setPositiveButton(R.string.proceed, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
text = input.getText().toString();
if(text.equals("ads")) //For example
...
}
})
...
Also, you can initially set the onClickListener
of the positive button to null and then override it as shown here https://stackoverflow.com/a/7636468/655987
It is up to you.