当我为我的 TextView 设置点击侦听器时,初始点击不会触发事件。这是文本视图:
<TextView
style="@android:style/Widget.EditText"
android:id="@+id/my_text_area"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:textColorHint="@color/text_hint"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
android:padding="10dip"
android:background="@android:color/transparent"
android:layout_weight="1"
></TextView>
// OnCreate:
TextView link = (TextView)findViewById(R.id.my_text_area);
// "this" is my Activity that implements OnClickListener
link.setOnClickListener(this);
void OnClick(view v) {
//only gets fired after the first time
}
当我单击 textview 时,会发生以下情况:
点击 1. textview 收到焦点
点击 2. OnClick 被触发
我也需要点击 1 来触发它