0

I want to create a TextView on my registration view which notifies about legal terms. So the text is smth. like: "By signing up you accept our privacy policy and terms and conditions."
Privacy Policy aswell as terms and conditions should be clickable and trigger a callback.

Coming from HTML by initial approach was to somehow add a link in there but those seem to be only for the web/browser-app.
So I thought about creating a nested layout containing the text as sepereate text like:

<LinearLayout /* ... */>
  <TextView android:text="By signing up you accept our "/>

  <TextView android:text="privacy policy" 
    android:clickable="true" 
    android:focusable="true" />

  <TextView android:text="and" />

  <TextView android:text="terms and conditions" 
    android:clickable="true" 
    android:focusable="true" />

  <TextView android:text="." />
</LinearLayout>

But this approach seems kinda odd, because I have to create so many elements and an additional layout. Are there any better solutions then my approach?

Code Spirit
  • 3,992
  • 4
  • 23
  • 34

2 Answers2

0

Set Text on Text View

textView.setText(Html.fromHtml("I have read and agree to the " +
        "<a href='app.activity.termsanduse://Kode'>Terms of Use</a>"));

Set Activity in Manifest

<activity
    android:name=".app.activity.TermsAndUse"
    android:screenOrientation="portrait">
    <intent-filter>
        <category android:name="android.intent.category.DEFAULT" />
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="app.activity.termsanduse" />
    </intent-filter>
</activity>
V-rund Puro-hit
  • 5,518
  • 9
  • 31
  • 50
Azay Gupta
  • 281
  • 2
  • 16
0

Define your string/statement in strings.xml(helps with localization as well)

Add this to your strings.xml

<string name="taclink"> By signing up you accept our <![CDATA[ <a href="http://web.com/xyz/Terms.html">Terms</a>]]>
     and <![CDATA[<a href="http://web.com/pqr/Privacy.html">Privacy Policy</a>]]></string>

In your java code set the "taclink" string resource textview,

termsandcondition.setText(Html.fromHtml(resources.getString(com.app.android.R.string.taclink)));
Ajay J G
  • 886
  • 7
  • 21