本文介绍了复制文本采用了android:textIsSelectable ="真"与onClicklistner在android的同一TextView中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我采用了android:textIsSelectable =真,让我的文字可享有复制文本,在同一TextView中我使用onclicklistner,但是clicklistner不会工作。当我删除的android:textIsSelectable =true,可以将正常工作。
我曾尝试设置onLong preSS听者到TextView的,使这个属性的运行时间。任何一个可以告诉我,任何其他解决方案?

I am using android:textIsSelectable="true" so that my text is eligible for copying text,On the same textview i am using onclicklistner,But that clicklistner wont work. As soon as i remove android:textIsSelectable="true" it will work fine. What i have tried set onLongpress listner to that textview and enable this property run time. Can any one tell me any other solution?

推荐答案

我见过的其他人,也有同样的问题。你应该做这样的事情。

I have seen other people too having same issue. You should do something like this.

包装你的的TextView 的LinearLayout ,然后将 onClickListener 上的LinearLayout,而不是在TextView的设置。这将有同样的影响。

Wrap your textView with LinearLayout and then set onClickListener on LinearLayout instead of setting on textView. It will have same impact.

<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 选择以及点击。

This will make your textView selectable as well as clickable.

这篇关于复制文本采用了android:textIsSelectable =&QUOT;真&QUOT;与onClicklistner在android的同一TextView中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 15:18