1
如何在點擊打開谷歌主頁上的android超鏈接文本視圖正在嘗試與它只是改變普通的文本,超鏈接下面的代碼,但是,點擊如何解決它如何在android中點擊文本視圖超鏈接打開Google頁面?
這裏是代碼:
MainActivity.java(在的onCreate())
instruction = (TextView) findViewById(R.id.example);
instruction.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
instruction.setText(Html.fromHtml(getString(R.string.Google_Instructions)));
Linkify.addLinks(instruction, Linkify.ALL);
instruction.setMovementMethod(LinkMovementMethod.getInstance());
}
});
的strings.xml
<string name="Google_Instructions">opens <a href="https://www.google.co.in">Google</a> page </string>
layout_test.xml
<TextView
android:id="@+id/example"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10sp"
android:clickable="true"
android:text="@string/Google_Instructions"
android:autoLink="web"
android:textSize="16sp" />
你想讓它在瀏覽器中打開嗎? –
http://stackoverflow.com/questions/7570239/android-linkify-text-spannable-text-in-single-text-view-as-like-twitter-twee。搜索,所以你會有很多類似的帖子 – Raghunandan
你想在你的應用中嵌入一個網頁瀏覽器,或者在你的設備上啓動默認瀏覽器。每個所需的代碼明顯不同 –