<ScrollView
android:id="@+id/id_scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:paddingTop="@dimen/_5sdp"
android:paddingBottom="@dimen/_5sdp">
<LinearLayout
android:id="@+id/id_main"
android:layout_width="wrap_content"
android:gravity="center_vertical"
android:layout_height="match_parent"
android:background="#ffffff"
android:paddingLeft="@dimen/_10sdp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/id_test"
android:layout_width="wrap_content"
android:gravity="center_vertical"
android:layout_height="match_parent"
android:background="#ffffff"
android:paddingLeft="@dimen/_10sdp"
android:orientation="vertical">
<TextView
android:id="@+id/id_key_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:text="@string/key_tv"
android:textStyle="bold"
android:paddingLeft="@dimen/_10sdp"
android:layout_marginRight="@dimen/_15sdp"/>
<TextView
android:id="@+id/id_value_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:background="#ffffff"
android:gravity="center_vertical"
android:paddingTop="@dimen/_10sdp"
android:paddingLeft="@dimen/_10sdp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
用于解析 url 的代码段:
Intent showDocumentInBrowserIntent = new Intent(Intent.ACTION_VIEW);
showDocumentInBrowserIntent.setData(Uri.parse(clickedItemInViewSanctioned.getmValue()));
startActivity(showDocumentInBrowserIntent);
我正在尝试将超链接(例如网址)添加到TextView
(id_value_tv),遗憾的是该链接无效。
请有人告诉我这里的问题是什么吗? 谢谢。
答案 0 :(得分:1)
你应该像这样使用setMovementMethod
:
myTextView.setText(Html.fromHtml("<a href=\"http://www.google.com\">google</a> "));
myTextView.setMovementMethod(LinkMovementMethod.getInstance());
答案 1 :(得分:0)
我正在使用
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
后来我用
替换了它 @Override
public boolean onTouch(View v, MotionEvent event) {
final int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN) {
if (fileValue.equals("No File")) {
showAlert("No file exists.", true);
} else {
Intent showDocumentInBrowserIntent = new Intent(Intent.ACTION_VIEW);
showDocumentInBrowserIntent.setData(Uri.parse(customListRowDataObj.getmValue()));
startActivity(showDocumentInBrowserIntent);
}
}
答案 2 :(得分:0)
//In XML
<TextView
android:text="@string/app_name"
android:id="@+id/titleTxtview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/ic_title_bg"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/white"
android:textStyle="bold"
custom:typeface="helvetica_bold" />
//In Java
titleTxtview1.setText(Html.fromHtml(EndMessage));
titleTxtview1.setMovementMethod(LinkMovementMethod.getInstance());