【问题标题】:How to show keyboard when starting a dialog?启动对话框时如何显示键盘?
【发布时间】:2019-09-02 06:59:00
【问题描述】:

我想在打开对话框时显示键盘。

这是我的代码:

var array: Array<String> = arrayOf("Edit", "Delete")
 val builder = AlertDialog.Builder(activityContext)
 builder.setTitle("Options:").setItems(array, DialogInterface.OnClickListener {dialog, which ->
        if(which == 0) { //edit
           val mDialogView = LayoutInflater.from(activityContext).inflate(R.layout.activity_contact_info_description_dialog, null)
           val mBuilder = AlertDialog.Builder(activityContext).setView(mDialogView).setTitle("File name")
           val mAlertDialog = mBuilder.show()
    }

【问题讨论】:

    标签: android kotlin dialog keyboard


    【解决方案1】:

    这会有所帮助

    AlertDialog.Builder builder1 = new AlertDialog.Builder(context);
    
    AlertDialog dialog = builder1.create();
    dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    dialog.show();
    

    【讨论】:

    • 我不明白这是什么...我没有对话框变量。阅读我的代码,我有 mDialogView mBuilder mAlertDialog
    • 您正在使用来自不同导入的 AlertDialog
    • 是的,我想使用 alertDialog
    • 很多example
    猜你喜欢
    • 2013-06-26
    • 1970-01-01
    • 2011-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多