//界面未加載完全而無(wú)法彈出軟鍵盤(pán),所以延遲粘衬,但是延遲的時(shí)間不確定
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
InputMethodManager inputManager = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(editText, 0);
}
},200);
//輸入框自動(dòng)彈出鍵盤(pán)
edt.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
});
edt.requestFocus();
edt.setSelection(edt.getText().length());//設(shè)置輸入框焦點(diǎn)置于文字后,默認(rèn)總是在內(nèi)容前