Android:禁用双击可点击的textview(Android: Disable double tap on clickable textview)
这是textview的xml
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="SIGN IN" android:id="@+id/signInTV" android:layout_gravity="center_horizontal" android:gravity="center" android:layout_weight="1" android:background="#EB7B59" android:textColor="#524656" android:clickable="true" android:onClick="signInButton" android:focusableInTouchMode="false"/>这是代码:
public void signInButton(View view) { TextView signInTV = (TextView) findViewById(R.id.signInTV); signInTV.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent showSignInActivity = new Intent(v.getContext(), SignInActivity.class); startActivity(showSignInActivity); } }); }为什么我仍然只能双击文本视图而不是单击?
This is the xml for the textview
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="SIGN IN" android:id="@+id/signInTV" android:layout_gravity="center_horizontal" android:gravity="center" android:layout_weight="1" android:background="#EB7B59" android:textColor="#524656" android:clickable="true" android:onClick="signInButton" android:focusableInTouchMode="false"/>This is the code:
public void signInButton(View view) { TextView signInTV = (TextView) findViewById(R.id.signInTV); signInTV.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent showSignInActivity = new Intent(v.getContext(), SignInActivity.class); startActivity(showSignInActivity); } }); }Why is it that i can still only double tap on the textview and not single tap?
最满意答案
您已经在单击事件处理程序中,并且您正在接收单击的View作为参数,因此无需再次找到它。 这应该启动Activity。
public void signInButton(View view) { Intent showSignInActivity = new Intent(v.getContext(), SignInActivity.class); startActivity(showSignInActivity); }You are already in the click event handler, and you are receiving the clicked View as parameter so there's no need to find it again. This should start the Activity.
public void signInButton(View view) { Intent showSignInActivity = new Intent(v.getContext(), SignInActivity.class); startActivity(showSignInActivity); }更多推荐
发布评论