Source:
public void restoreWalletFromMnemonic() { final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.restore_wallet_mnemonic_dialog, null); final EditText input = (EditText) view.findViewById(R.id.import_mnemonic); final DialogBuilder builder = new DialogBuilder(WalletActivity.this); builder.setTitle(R.string.import_mnemonic); builder.setView(view); builder.setPositiveButton(R.string.button_ok, null); builder.setNegativeButton(R.string.button_cancel, null); builder.setCancelable(false); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(final DialogInterface d) { final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); positiveButton.setTypeface(Typeface.DEFAULT_BOLD); positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final List<String> codes = Arrays.asList(input.getText().toString().split("\\s+")); final DeterministicSeed seed = new DeterministicSeed(codes, null, "", wallet.getEarliestKeyCreationTime()); restoreWallet(Wallet.fromSeed(Constants.NETWORK_PARAMETERS, seed)); d.dismiss(); } }); positiveButton.setEnabled(false); input.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { positiveButton.setEnabled(count > 0 && s.toString().split("\\s+").length == 12); } @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public void afterTextChanged(final Editable s) { } }); input.requestFocus(); } }); dialog.show(); }

Target:
public void restoreWalletFromMnemonic() { final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.restore_wallet_mnemonic_dialog, null); final EditText input = (EditText) view.findViewById(R.id.import_mnemonic); final DialogBuilder builder = new DialogBuilder(WalletActivity.this); builder.setTitle(R.string.import_mnemonic); builder.setView(view); builder.setPositiveButton(R.string.button_ok, null); builder.setNegativeButton(R.string.button_cancel, null); builder.setCancelable(false); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(final DialogInterface d) { final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); positiveButton.setTypeface(Typeface.DEFAULT_BOLD); positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final List<String> codes = Arrays.asList(input.getText().toString().split("\\s+")); final DeterministicSeed seed = new DeterministicSeed(codes, null, "", MnemonicCode.BIP39_STANDARDISATION_TIME_SECS); restoreWallet(Wallet.fromSeed(Constants.NETWORK_PARAMETERS, seed)); d.dismiss(); } }); positiveButton.setEnabled(false); input.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { positiveButton.setEnabled(count > 0 && s.toString().split("\\s+").length == 12); } @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public void afterTextChanged(final Editable s) { } }); input.requestFocus(); } }); dialog.show(); }