zoukankan      html  css  js  c++  java
  • ExpandableListView的OnitemLongclickListener事件

    expandableListView是带分组的Listview,通常会有setOnChildClickListener,setOnGroupClickListener,但如果是长按的事件,可以用以下方法来实现长按事件的监听

    elv.setOnItemLongClickListener(new OnItemLongClickListener() {
                  @Override
                  public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                      int itemType = ExpandableListView.getPackedPositionType(id);
    
                      if ( itemType == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
                          childPosition = ExpandableListView.getPackedPositionChild(id);
                          groupPosition = ExpandableListView.getPackedPositionGroup(id);
                          Toast.makeText(getApplicationContext(), "childPosition"+childPosition+"groupPosition"+groupPosition, 0).show();
                          //do your per-item callback here
                          return true; //true if we consumed the click, false if not. consume : 消耗
    
                      } else if(itemType == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
                          groupPosition = ExpandableListView.getPackedPositionGroup(id);
    
                          Toast.makeText(getApplicationContext(),"groupPosition"+groupPosition, 0).show();
                          //do your per-group callback here
                          return true; //true if we consumed the click, false if not
    
                      } else {
                          // null item; we don't consume the click
                          return false;
                      }
              }});
  • 相关阅读:
    Mysql 从入门到遗忘
    Centos7开放及查看端口
    创建及修改数据库
    02_python是一种什么语言?
    03_SQL server数据类型
    02_关系数据库
    01_初识数据库
    kali 更新源
    01_Python简介
    Alertmanager高可用
  • 原文地址:https://www.cnblogs.com/yiludugufei/p/4583463.html
Copyright © 2011-2022 走看看