其实很简单,把selectall放在show后面就行了
final EditText input = new EditText(this);
input.setText("XXX");
new AlertDialog.Builder(this).XXXX.show();
input.selectAll()
再补充下,如果需要弹出输入对话框,并且全选默认值,并且弹出输入法,结合上面的selectall和下面的代码段即可
final AlertDialog dialog = ...;
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
});