私のアンドロイドアプリケーションActivity
には、複数のクリック可能なテキストを含むTextView
があります。私はそれらをクリック可能にするためにLinkify
を使用しました。しかし、問題は彼らがクリック時にウェブURLを呼び出さないということです。これをどうすれば解決できますか?Android:リンクテキストonclickがウェブURLを呼び出さない
以下は私のコードです。
String termsAndConditions = "Terms and Conditions";
String privacyPolicy = "Privacy Policy";
txtLinkfy.setText(
String.format(
"By tapping to continue, you are indicating that " +
"you have read the Privacy Policy and agree " +
"to the Terms and Conditions.",
termsAndConditions,
privacyPolicy)
);
txtLinkfy.setMovementMethod(LinkMovementMethod.getInstance());
Pattern termsAndConditionsMatcher = Pattern.compile(termsAndConditions);
Linkify.addLinks(txtLinkfy, termsAndConditionsMatcher,"http://myexample.in/termsofservice");
Pattern privacyPolicyMatcher = Pattern.compile(privacyPolicy);
Linkify.addLinks(txtLinkfy, privacyPolicyMatcher, "http://myexample.in/privacypolicy");
とのAndroidManifest.xmlで:
<activity android:name=".view.ActivityContinue"
android:label="@string/app_name">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="Terms and Conditions" />
<data android:scheme="Privacy Policy" />
</intent-filter>
</activity>
これはうまくいくかもしれませんが、代わりにLinkrefメソッドを使用してhrefのリンクを使用するのが好きです。 – KJEjava48