リストビューの行にハイパーリンク(ハイパーリンクとして形式化されている)を表示しようとしていますが、運が足りません。Android:ListFragmentのハイパーリンクリストビューの行
public void setNews(){
TextView textcontent = (TextView) news_row.findViewById(android.R.id.text2);
textcontent.setMovementMethod(LinkMovementMethod.getInstance());
String[] matrix = {"_id", "title", "content", "date"};
String[] columns = {"title", "content", "date"};
int[] layouts = {android.R.id.text1,android.R.id.text2, R.id.text3};
MatrixCursor cursor = new MatrixCursor(matrix);
for(int i = 0 ; i < straNewsTitle.length; i++) {
cursor.addRow(new Object[] {i, straNewsTitle[i], Html.fromHtml(straNewsContent[i]), straNewsDate[i] });
}
SimpleCursorAdapter a = new SimpleCursorAdapter(fa, R.layout.news_row, cursor, columns, layouts);
setListAdapter(a);
}
straNewsContentは、本文テキストを保持している:まず、私は、行の人気そしてonActivityCreateでsetNewsを呼び出し、ハイパーリンクでのTextViewを探し、後に
news_row = (LinearLayout) inflater.inflate(R.layout.news_row,null);
ためonCreateViewでクラス変数にnews_rowビューを膨らませますHTMLハイパーリンクタグを含むかもしれないニュース項目のために。マイnews_rowレイアウト:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffefe5" android:orientation="vertical" android:paddingLeft="15px" android:paddingRight="15px" android:paddingBottom="5px" android:paddingTop="5px">
<TextView
android:id="@android:id/text1"
android:gravity="top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#666666"
android:textSize="20dp"
android:background="#ffefe5"
android:textStyle="bold"
/>
<TextView
android:id="@android:id/text2"
android:gravity="bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@android:id/text1"
android:textColor="#666666"
android:textSize="15dp"
android:background="#ffefe5"
android:autoLink="web|email"
/>
<TextView
android:id="@+id/text3"
android:gravity="bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@android:id/text1"
android:textColor="#666666"
android:textSize="12dp"
android:background="#ffefe5"
/>
</LinearLayout>
アンドロイド:オートリンク=「ウェブ|電子メールには、」URLをフォーマットされますが、HTMLタグがレンダリングされていない文字列の素晴らしい作品。どんな助けも素晴らしいだろう。
私は既にHTML.fromHTMLを使用しています。 – Scott