我不知道如何在点击upload按钮时显示下面的对话框。
var image = findViewById<ImageView>(R.id.image)
var uploadBtn = findViewById<Button>(R.id.uploadBtn)
uploadBtn.setOnClickListener {
// how can I display dialogue or action sheet box on this click listener
}
发布于 2019-10-05 17:40:14
下面的函数用于显示BottomSheet并创建自定义布局,并传递inflate(此处)
private fun showBottomSheetDialog() {
val view = layoutInflater.inflate(R.layout.your_sheet_layout, null)
val dialog = BottomSheetDialog(this)
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
dialog.setCancelable(true)
dialog.setContentView(view)
view.textViewcamer.setOnClickListener {
Toast.makeText(this, "Camera", Toast.LENGTH_SHORT).show()
}
view.textViewGallery.setOnClickListener {
Toast.makeText(this, "Gallery", Toast.LENGTH_SHORT).show()
}
view.textViewCancel.setOnClickListener {
Toast.makeText(this, "Cancel", Toast.LENGTH_SHORT).show()
}
dialog.show()
}
https://stackoverflow.com/questions/58246992
复制相似问题