setOnLongClickListener 返回值的作用
来源:互联网 发布:java web开发与实战 编辑:程序博客网 时间:2024/06/07 21:14
直接说结果 : 返回值是false(默认) 则长按时执行完长按监听之后会走点击的监听
返回值是true 则长按时只会执行setOnLongClickListener
下面是验证,可以不看- -。
布局文件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.administrator.zzz.MainActivity"> <Button android:id="@+id/btn1" android:text="返回值为false" android:layout_width="match_parent" android:layout_height="wrap_content"/> <Button android:id="@+id/btn2" android:text="返回值为true" android:layout_width="match_parent" android:layout_height="wrap_content"/></LinearLayout>
MainActivity
public class MainActivity extends AppCompatActivity implements View.OnClickListener, View.OnLongClickListener { private Button btn1, btn2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn1 = (Button) findViewById(R.id.btn1); btn2 = (Button) findViewById(R.id.btn2); btn1.setOnClickListener(this); btn2.setOnClickListener(this); btn1.setOnLongClickListener(this); btn2.setOnLongClickListener(this); } @Override public void onClick(View view) { Toast.makeText(this, "短按", Toast.LENGTH_SHORT).show(); } @Override public boolean onLongClick(View view) { switch (view.getId()) { case R.id.btn1: Toast.makeText(this, "长按", Toast.LENGTH_SHORT).show(); return false; case R.id.btn2: Toast.makeText(this, "长按", Toast.LENGTH_SHORT).show(); return true; } return true; }}
阅读全文
0 0
- setOnLongClickListener 返回值的作用
- android setOnLongClickListener中return值
- onTouchEvent返回值的作用
- onTouchEvent返回值的作用
- return 的返回值作用,
- return返回值的作用
- linux 返回值的作用
- update方法返回值的作用
- strcpy函数返回值的作用
- const作为函数返回值的作用
- 中断处理例程返回值的作用?
- strcpy函数返回值的作用
- 返回值的第二个作用
- setOnLongClickListener setWallPaper
- onOptionsItemSelected返回值作用
- @@identity的作用是返回最后插入的标识值
- Cocos2d-x CCTouchBegin 的bool返回值的作用
- view,viewGroup 的onTouchEvent返回值的作用
- 面试题之数据库中事务及其四个特性
- 使用swp恢复VI丢失的文件
- MyBatis笔记二-增删改查-事务-简单的多表联查
- int、bigint、smallint和tinyint范围
- Map.get()方法要注意其返回值为null
- setOnLongClickListener 返回值的作用
- ReadFile ReadFileEx异步操作 控制台程序
- 分析tensorflow代码(Hello world)
- 通过npm安装webpack
- MySql存储过程的异常处理理论及实例
- android 增加自己的应用签名校验
- Lucene 在Ubuntu+Python2的环境下进行搜索
- 关于微信支付
- 基础认证伪造工具phishery