Android中listview中的button

  在androd中的listview中,假如每一项是个buuton,要针对这个button有响应
事件,比如跳到另外一个activity的话,可以这样做:


<Button
 
        android:id="@+id/btnaccno"
 
        style="?android:attr/buttonStyleSmall"
 
        android:layout_width="wrap_content"
 
        android:layout_height="wrap_content"
 
        android:text="View"
 
        android:focusable="false"
 
android:focusableInTouchMode="false" 

 android:onClick="myClick"
 
        />

   注意的是必须加上 android:focusable="false"

android:focusableInTouchMode="false"
 
然后就可以写响应的事件了

public void myClick (View v) 

..........

猜你喜欢

转载自jackyrong.iteye.com/blog/1625198