@SuppressLint("InflateParams") // no other way for AlertDialog private Dialog createSignInDialog( final HttpAuthHandler handler, final String host, final String realm, final String username, final String password) { final View v = mIitc.getLayoutInflater().inflate(R.layout.dialog_http_authentication, null); final TextView tvUsername = (TextView) v.findViewById(R.id.username); final TextView tvPassword = (TextView) v.findViewById(R.id.password); final String title = String.format(mIitc.getString(R.string.sign_in_to), host, realm); if (username != null) tvUsername.setText(username); if (password != null) tvPassword.setText(password); return new AlertDialog.Builder(mIitc) .setView(v) .setTitle(title) .setCancelable(true) .setPositiveButton( R.string.sign_in_action, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int id) { handler.proceed(tvUsername.getText().toString(), tvPassword.getText().toString()); } }) .setNegativeButton( android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); } }) .setOnCancelListener( new DialogInterface.OnCancelListener() { @Override public void onCancel(final DialogInterface dialog) { handler.cancel(); } }) .create(); }