在我的申请中,我有一些条款和条件的文本.
By registering you agree to be bound by our Terms of Use and that you have read our Privacy Policy.
使用条款和隐私政策应该是可点击的,并显示一个警告框.
首先,我尝试将句子分成四个TextView:
>通过注册,您同意受我们的约束
>使用条款
>你已经读过我们了
>隐私政策.
这很好用,具有以下布局XML:
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" >
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" />
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" />
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" />
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" />
显示弹出窗口的代码是:
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();
问题是四个TextView没有正确对齐.
这意味着当单击TextView中的特定单词(使用条款,隐私策略)时,我必须使用一个TextView并显示弹出式diaplog.
做这个的最好方式是什么?