入力ダイアログを開くコードは次のとおりです。
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Dialog Title");
alert.setMessage("Request information");
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.edittextautotextlayout, null);
final EditText inputBox = (EditText) textEntryView.findViewById(R.id.my_et_layout);
alert.setView(inputBox);
ソフト キーボードが表示される前にテキスト入力行をタップする必要があることを除いて、これは正常に機能します。
ここで与えられたアドバイスに従って、挿入しようとしました:
inputBox.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
alert.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
});
しかし、「メソッド getWindow() はタイプ AlertDialog.Builder に対して定義されていません」という Eclipse オブジェクト。
setOnFocusChangeListener コードは AlertDialog オブジェクトでは機能しますが、AlertDialog.Builder では機能しないようです。ソフト キーボードが自動的に表示されるようにするには、コードをどのように変更すればよいですか。