BaseExpandableListAdapter找出单击项目的组

时间:2014-02-12 15:54:12

标签: android checkedtextview

我在BaseExpandableListAdapter的行中已经BaseExpandableListViewCheckedTextView我有BaseExpandableListView。我想要实现的是@Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { ... holder.checkedTextView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((CheckedTextView) v).toggle(); } }); holder.checkedTextView.setText(person.getName()); holder.checkedTextView.setChecked(person.isTracked()); return convertView; } 中的一个组中只能检查项目。

因此,如果组0中已经检查过项目并且用户尝试检查组1中的任何项目,那么应该显示一个toast消息,说明他必须取消选中组0中的项目或类似的东西。

到目前为止,我的代码看起来像这样:

BaseExpandableListView

我想我需要在onClick方法中获取CheckedTextView的引用或内容,以找出当前切换的{{1}}内的哪个组?

我不确定我的术语是否正确,因为我刚开始在Android上编码。

1 个答案:

答案 0 :(得分:0)

我想出了如何使用int groupPosition, int childPosition变量。

相关问题