In my application, I have text for conditions.
By registering, you agree to abide by our Terms of Use and that you have read our Privacy Policy.
The terms "Terms of Use and Privacy Policy" should be clickable and display a warning window.
At first I tried splitting sentences into four TextView s:
- By registering, you agree to our
- Terms of Use
- and what did you read our
- Privacy policy.
This worked well, with the following XML location:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/termsandcondtion" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:orientation="horizontal" > <TextView android:id="@+id/terms_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/terms_1" android:textColor="#000000" android:textSize="12dp" /> <TextView android:id="@+id/terms" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="true" android:onClick="showTerms" android:text="@string/terms_2" android:textColor="#000000" android:textSize="12dp" /> <TextView android:id="@+id/terms_3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/terms_3" android:textColor="#000000" android:textSize="12dp" /> <TextView android:id="@+id/termsofuse" android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="true" android:onClick="showTermsofUse" android:text="@string/terms_4" android:textColor="#000000" android:textSize="12dp" /> </LinearLayout>
Code to display popup:
WebView wv = new WebView(this); wv.loadUrl(url); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Privacy Policy"); alert.setView(wv); alert.setNegativeButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); alert.show();
The problem is that the four TextView not aligned correctly with each other. This means that I have to use one TextView and display a popup dialog when a certain word is clicked (Terms of Use, Privacy Policy) in TextView .
What is the best way to do this?
source share