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;
                      }
              }});
  • 相关阅读:
    oracle锁分类
    oracle中decode函数
    oracle分区
    oracle处理字符串
    oracle索引分类
    oracle表连接
    oracle处理字符串
    oracle分区
    木马中如何编程实现远程关机
    木马中如何编程实现远程关机
  • 原文地址:https://www.cnblogs.com/yiludugufei/p/4583463.html
Copyright © 2011-2022 走看看