当我单击附件按钮时,它仅向我显示警报对话框的标题。那么如何在警报对话框中显示该选项

问题描述 投票:-1回答:1

这是一个聊天应用程序,我想在用户单击附件按钮时显示选项,并选择一个选项,例如他想向其他用户发送图片或视频或文件文档。like this screenshot

但是我失败了,当我单击附件按钮时,它仅向我显示警报对话框的标题。like this screenshot

这是我的附件按钮代码,有些东西我错过了或....

        attachment.setOnClickListener {
        val option: Charsequence = Charsequence("Images" , "Videos" , "File Documents")
        val itemList = arrayOf("Images","Videos","File Documents")
        val builder = AlertDialog.Builder(this@ChatLogActivity)
        val title = builder.setTitle("Select The File")
        builder.setItems( itemList.toString() ,
            onClickListener = DialogInterface.OnClickListener { dialogInterface , i ->
                if (i == 0){
                    checker = "Images"
                    val intent = Intent(Intent.ACTION_GET_CONTENT)
                    intent.type = "image/*"
                    startActivityForResult(Intent.createChooser(intent, "Select Image"),438)
                }

                if (i == 1){
                    checker = "Videos"
                    val intent = Intent(Intent.ACTION_GET_CONTENT)
                    intent.type = "video/*"
                    startActivityForResult(Intent.createChooser(intent, "Select Video"),439)
                }

                if (i == 2){
                    checker = "File Documents"
                    val intent = Intent(Intent.ACTION_GET_CONTENT)
                    intent.type = "application/pdf"
                    startActivityForResult(Intent.createChooser(intent, "Select File Documents"),440)
                }
            })
        builder.show()
    }
firebase kotlin android-alertdialog
1个回答
0
投票

您需要这样设置阵列适配器。如果它对您有帮助,则将其标记为接受。

© www.soinside.com 2019 - 2024. All rights reserved.