0

String using this one:

String stringConvertor="We are looking for talented individuals who share our values and <a href='http://www.precipeace.com/about/' target='_blank'>mission</a>.  What is your motivation for joining our company?","quesNo":1,"__v":0,"isDelete":false,"createdAt":"2017-08-16T11:51:05.644Z"},{"_id":"599431be8eedf235d9965a08","question":"Currently, we utilize coaching techniques like CBT, positive psychology, and other solution focused techniques to help our clients. <br class='breakclass'/><br class='breakclass'/> Are you familiar and capable of utilizing these techniques or open to learning about them?  What other techniques do you have experience with that you feel would benefit your future clients?"

Code:

<TextView
      android:id="@+id/txt_screening_question"
      android:layout_width="match_parent"
      android:gravity="center"
      android:layout_height="wrap_content"
      android:paddingBottom="@dimen/text_size_medium"
      android:textSize="@dimen/text_size_medium"
      android:autoLink="web"
      android:linksClickable="true"
      android:text="We are looking for talented individuals who share our values and mission. What is your motivation for joining our company?"
      android:textColor="@color/colorGrey"/>

Java code:

Linkify.addLinks(txtScreeningQuestion, Linkify.WEB_URLS);
txtScreeningQuestion.setText(Html.fromHtml(stringConvertor));

Provide me Solutions how to perform click on it Please give me any solutions how to perform click on anchor tag string

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
mehta mehta
  • 111
  • 7
  • Please use this one code.Here you can got it url and perform functionality after click on anchor tag. Please follow these link: https://stackoverflow.com/questions/12418279/android-textview-with-clickable-links-how-to-capture-clicks/19989677#19989677 – mehta mehta Oct 25 '17 at 13:01

1 Answers1

1

Try saving your string in strings.xml in following format.

<string name="welcome">
<![CDATA[ Welcome to <a href=\'http://www.google.com\'>Google</a>.]]>
</string>

Then assign the string to your TextView as following:

 Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(getString(R.string.welcome)));
            PackageManager manager = getPackageManager();
            List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);

            if (infos.size() > 0) {
                //At least one application can handle your intent
                //Put this code in onCreate and only Linkify the TextView from here
                //instead of using android:autoLink="web" in xml
                Linkify.addLinks(txtScreeningQuestion, Linkify.ALL);
                // or tvTextView.setAutoLinkMask(Linkify.WEB_URL), 
            }
    txtScreeningQuestion.setText(Html.fromHtml(getString(R.string.welcome));
Akhilesh Awasthi
  • 2,688
  • 4
  • 21
  • 30