问题描述
我设计一个应用程序,其中有TextView的,并根据一些检查条件,我想使链接/电话号码在Java方面TextView的点击。我可以做这个,我不想让它点击默认情况下它是由在XML文件中设置完成。
I am designing an App, where there is TextView, and based on some check condition, I want to make links / phone numbers in the TextView clickable in Java side. Can I do this, I don't want to make it clickable by default which is done by setting in xml file
android:autoLink="all"
我已经尝试过:
创建TextView的定期和不设置自动链接=所有,
What I already tried:Create regular TextView and don't set autoLink="all",
TextView myView =
(TextView)view.findViewById(R.id.thisIstheTextView);
myView .setLinksClickable(true);
也试过:
myView .setMovementMethod(LinkMovementMethod.getInstance());
上面的Java code ++工程,没有,我不想pdesigned XML的TextView启用自动链接,我想改变,如果()条件,基于Java中code TextView的行为$ P $。有一个在我的code没有错误,但我没能达到我想要的。能否请您分享你的知识。谢谢。
None of the above Java code works, I don't want a predesigned xml TextView with autoLink enabled, I want to change the TextView behavior in Java code based on if () conditions. There is no error in my code, but I am not able to achieve what I want. Can you please share your knowledge. Thank you.
推荐答案
Linkify.addLinks(MyView的,Linkify.ALL);
固定的问题。
Linkify.addLinks(myView, Linkify.ALL);Fixed the issue.
这篇关于设置可点击的链接在Java的Android版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!