gpt4 book ai didi

android - 使用android :textIsSelectable ="true" is not working with onClicklistner on same textview in android复制文本

转载 作者:行者123 更新时间:2023-11-30 02:20:01 38 4
gpt4 key购买 nike

我正在使用 android:textIsSelectable="true"以便我的文本有资格复制文本,在同一个 TextView 上我正在使用 onclicklistner,但是那个 clicklistner 将无法工作。只要我删除 android:textIsSelectable="true"它就会正常工作。我尝试将 onLongpress listner 设置为该 textview 并启用此属性运行时。任何人都可以告诉我任何其他解决方案吗?

最佳答案

我看到其他人也有同样的问题。你应该做这样的事情。

LinearLayout 包装您的 textView,然后在 LinearLayout 上设置 onClickListener 而不是在 textView 上设置。它会产生同样的影响。

<LinearLayout
android:id="@+id/layout"
android:layout_height="wrap_content"
android:layout_width="wrap_content">

<Button
android:id="@+id/button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textIsSelectable="true">
</LinearLayout>

.class 文件中的新内容

LinearLayout mLayout = (LinearLayout) findViewById(R.id.layout);
mLayout.setOnClickListener(new View....) {
...
// Do something here.
}

这将使您的 textView 既可选择又可点击。

关于android - 使用android :textIsSelectable ="true" is not working with onClicklistner on same textview in android复制文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28711962/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com