I want to put a web link in my TextView
. I am using the TextView
in my fragment. I think it does not work on an emulator. I changed the emulator and still got the same problem.
Here are the solutions I've tried:
- How to open URL from Fragment TextView?
- Android - Hyperlink is not clickable
- Why link does not work in the text view?
My TextView
inside linearLayout
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/privacy_policy"
android:textColor="@color/colorPrimary"
android:padding="10dp"
android:textSize="17sp"
android:textStyle="bold"
android:autoLink="all"
android:clickable="true"
android:focusable="true"
android:linksClickable="true"
android:id="@+id/tv_privacy_policy" />
My string value
<string name="privacy_policy">Privacy Policy<a href="https://csunix.mohawkcollege.ca/~000762465/Privacy%20Policy/ielts_up.html"></a></string>
My onCreateView()
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_aboutus, container, false);
TextView tv_privacy_policy = (TextView)rootView.findViewById(R.id.tv_privacy_policy);
// Linkify.addLinks(tv_privacy_policy, Linkify.WEB_URLS);
// Inflate the layout for this fragment
tv_privacy_policy.setMovementMethod(LinkMovementMethod.getInstance());
String text = "<a href='http://www.google.com'>Pricacy Policy</a>";
tv_privacy_policy.setText(Html.fromHtml(text));
return rootView;
}