TextView onclick事件无法正常工作

use*_*494 1 android onclick textview

在我的Android代码中,我onclick使用以下代码在3个textviews上实现了事件.但点击它们没有任何反应.怎么了 ?

 <TextView 
 android:id="@+id/tv1"
 android:layout_width="40dp"
 android:layout_height="40dp"
 android:background="@drawable/menucircle"
 android:layout_alignParentLeft="true"
 android:layout_centerVertical="true"
 android:onClick="selectit"
 android:textColor="#ffffff"
/>


public void selectit(View v)
{
    Log.d("tv0","ok");
    if(v.getId()==tv1.getId())
    {Log.d("tv1","ok");
        selectoption(1);
        Log.d("tv1","ok");
    }
    if(v.getId()==tv2.getId())
    {Log.d("tv2","ok");
        selectoption(2);
    }
    if(v.getId()==tv3.getId())
    {Log.d("tv3","ok");
        selectoption(3);
    }
}
Run Code Online (Sandbox Code Playgroud)

Has*_*'98 13

将其添加到您的xml中

android:clickable="true"
Run Code Online (Sandbox Code Playgroud)