Android是否有类似于复选框的onListClickView的方法?

Android是否有类似于复选框的onListClickView的方法?,android,Android,所以我的问题是标题:Android有没有一种类似于复选框的onListClickView的方法 我有一个方法onListClickView来获取列表被触摸的位置,并从列表中的该位置获取信息 protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); TextView label = ((TwoLineLi

所以我的问题是标题:Android有没有一种类似于复选框的onListClickView的方法

我有一个方法onListClickView来获取列表被触摸的位置,并从列表中的该位置获取信息

protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    TextView label = ((TwoLineListItem) v).getText2();
    String phoneNumber = label.getText().toString();
    Toast.makeText(this, "Selected " + phoneNumber, Toast.LENGTH_SHORT).show();
}

这是我拥有的方法,但我不知道我可以使用类似的方法为选中的框获取相同的信息。有人能解释一下我遇到的这个问题吗?

您可以收听正在单击的复选框:

CheckBox check = (CheckBox) findViewById(R.id.check_box);
check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override public void onCheckedChanged(CompoundButton button, boolean isChecked) {
        // The checkbox has been clicked - do something interesting
    }
});

这将允许我查看复选框是否被选中,但不会告诉哪个复选框被选中。这就是我需要从相应的文本中检索电话号码的地方。这已经足够接近我想要的了。我相信我可以在web上查找函数,以获取复选框的行位置。非常感谢。