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 三大特性详解
    MySQL Innodb日志机制深入分析
    Bootstrap学习地址
    Java【锁】
    Java【tomcat】配置文件
    nginx配置文件详解【nginx.conf】
    Sqlserver2008[索引]
    网络知识
    RestClient火狐接口测试地址
    java基础1JDK各大版本下载地址
  • 原文地址:https://www.cnblogs.com/yiludugufei/p/4583463.html
Copyright © 2011-2022 走看看