2010-08-10 5 views
0

Je veux faire une application qui est assez similaire au client Twitter officiel pour android.Comment faire des liens HTML dans un listView Elément focalisable?

Dans mon listView article, il y a une TextView qui a un contenu html, j'espère que les liens à l'intérieur il peut être focalisable et cliquable, je l'ai utilisé:

getListView().setItemsCanFocus(true); 

mais il ne fonctionne toujours pas, Je ne sais pas pourquoi.

la mise en page est comme ceci:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/item" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal" 
android:padding="6dip" 
android:background="#FFFFFF"> 
<ImageView android:id="@+id/avatar" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:layout_marginRight="6dip" 
    android:src="@drawable/default_happy_face" /> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <RelativeLayout 
     android:id="@+id/linearBanner" 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="20dip"> 
    <TextView android:id="@+id/txtNickname" 
     android:layout_width="wrap_content" 
    android:textColor="#1C86EE" 
    android:text="mmLiu" android:layout_height="fill_parent"/> 
    <ImageView android:id="@+id/verified" 
      android:layout_width="24dip" 
      android:layout_height="24dip" 
      android:paddingLeft="4dip" 
      android:layout_toRightOf="@id/txtNickname" 
      android:background="@drawable/verified"/> 
     <TextView android:id="@+id/txtTime" 
     android:textColor="#999999" 
     android:layout_height="fill_parent" 
     android:layout_alignTop="@+id/txtNickname" 
     android:layout_alignRight="@layout/notice_item" android:layout_toRightOf="@+id/verified" android:layout_width="fill_parent" android:gravity="right" android:text="半个小时前"/> 
    </RelativeLayout> 
    <TextView android:id="@+id/txtContent" 
     android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textColor="#050505" 
    android:text="!时尚起义 波点连衣裙原价116,现价69素雅波点拼接长裙,素色上装搭配雪纺波点短裙,优雅恬静,非你莫属!【商家地址:http://1net.cn/8wf】#服饰#" android:clickable="true"/> 
</LinearLayout> 
</LinearLayout> 

J'espère que les liens peuvent se concentrer à la place de tout l'article, cette question a été discutée dans le google io, voir here et la solution est getListView(). setItemsCanFocus (true); Mais ça ne marche pas pour moi.

J'ai utilisé un adaptateur comstimized qui étend le BaseAdapter, je ne sais pas si cela a sth à faire avec.

quelqu'un? de l'aide ?

Répondre

0

trouvé la solution par moi-même:

si vous voulez que le lien cliquable TextView, vous devez ajouter une ligne supplémentaire:

yourTextView.setMovementMethod(LinkMovementMethod.getInstance()); 

en plus

getListView().setItemsCanFocus(true); 

C'est tout.

voir le lien: here

Questions connexes