android - 点击文本并在 android studio 中显示弹出消息
问题描述
我的应用中有一些文本是我在 android studio 中使用 kotlin 创建的。对于这个应用程序,我想保留一条弹出消息,以便我点击文本,一个小的弹出窗口会在该弹出窗口中向我显示相同的文本。我正在使用回收站视图。UI 的快照如下所示。
因此,我应该能够点击文本并获得包含相同文本的弹出消息。由于我是 android studio 的业余爱好者,因此我需要一些帮助。我一直在搜索并找到类似的解决方案Dialog
,AlertDialog
但我不知道在这种情况下应该如何使用它们。顺便说一句,这里没有按钮,它是一个简单的 textView。
任何帮助表示赞赏。
解决方案
我找到了一种使用AlertDialog
. 下面给出了对我有用的代码片段。
val mAlertDialogTextView = holder?.view?.textView_subtopic_title //textView_subtopic_title is the view of my choice which needs to popup a message.
mAlertDialogTextView?.setOnClickListener {
val mAlertDialog = AlertDialog.Builder(context)
mAlertDialog.setMessage(key.toString())
mAlertDialog.setNegativeButton("cancel",{ dialogInterface: DialogInterface, i: Int -> dialogInterface.dismiss()})
mAlertDialog.show()
}
谢谢大家的支持。
推荐阅读
- python - 如何在seaborn python中组合两个relplots?
- python - 句子从 gensim.corpora 返回空字典
- intellij-idea - IntelliJ Idea 社区版 - 如何在一个项目中运行所有 Dart 单元测试
- matlab - 在信号中找到零交叉点并绘制它们matlab
- javascript - 悬停具有多个部分的图像时更改内容/图像
- mapbox - Mapbox GL JS:某些坐标未渲染
- postgresql - 无法在 pgAdmin 4 上查询数据,但可以使用 psql 和 Python
- amazon-web-services - 手动触发 AWS CloudWatch 事件
- css - JSX 中有什么反应
我有一个简单的反应组件,它在 JSX 属性
css
中,我理解它是用于样式的这个道具,但不清楚它是否是“本机”css 反应属性,或者它是否来自styled-components
其他库。如果不是反应库,您是否知道它来自哪个库?
<div css={{color: 'red', backgroundColor:'bl
- java - 从弹簧休息控制器返回对象中的文件