Android:禁用双击可点击的textview(Android: Disable double tap on clickable textview)

编程入门 行业动态 更新时间:2024-10-26 19:25:29
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); }

更多推荐

本文发布于:2023-07-26 10:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1274345.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:双击   textview   Android   Disable   clickable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!