ExpandableListview中包含很多子条目项,每个子条目项中拥有一个按钮,现在想获取这个按钮的点击事件,谁能只带你一下

解决方案 »

  1.   

    class ListAdapter extends BaseExpandableListAdapter {
          ...
          ...
          @Override
          public View getChildView(int groupPosition, int childPosition,
    boolean isLastChild, View convertView, ViewGroup parent) { View view = null; if (null != convertView) {
    view = convertView;
    } else {
    view = View.inflate(context, R.layout.childview, null);
    } Button button = (Button) view.findViewById(R.id.video_cover);
    button .setOnClickListener(listener);
    return view;
    }
    }
      

  2.   

    这个listener也是在这个类里边写吗?
      

  3.   

    ExpandableListView实例(一)_数据库增删改查处理和listitem点击长按处理
    http://blog.csdn.net/lk_blog/article/details/7562987ExpandableListView实例(二)_两种方式实现QQ中组后面显示子条目数量效果
    http://blog.csdn.net/lk_blog/article/details/7563355ExpandableListView实例(三)_实现QQ中"未分组"效果和"未分组"不可编辑删除功能
    http://blog.csdn.net/lk_blog/article/details/7563371
      

  4.   

    单击事件: mExpandableListView.setOnChildClickListener(new OnChildClickListener() {
    @Override
    public boolean onChildClick(ExpandableListView parent, View v,
    int groupPosition, int childPosition, long id) {
    //TODO
    return true;
    // must return false for handle this event by the super listener
    // ,or true for not
    }
    });长按事件
    view.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenuInfo menuInfo) {
    try {
    ExpandableListView.ExpandableListContextMenuInfo info 
    = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    int type = ExpandableListView
    .getPackedPositionType(info.packedPosition);
    int group = ExpandableListView
    .getPackedPositionGroup(info.packedPosition);
    int child = ExpandableListView
    .getPackedPositionChild(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {

    //TODO