如何监听在ListView行中的复选框? [英] How to listen for a checkbox in a listview row?

查看:98
本文介绍了如何监听在ListView行中的复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

String[] from = new String[] { CallrzDbAdapter.C_NAME,CallrzDbAdapter.C_EMAIL,CallrzDbAdapter.C_PHONE };
    int[] to = new int[] {R.id.cName, R.id.cEmail, R.id.cPhone };


    notes = new SimpleCursorAdapter(this,
            R.layout.row, cursor, from, to);

    ListView view =getListView();
    view.setHeaderDividersEnabled(true);
    view.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    view.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View view,
                int position, long arg3) {
            Toast.makeText(getApplicationContext(), "Hello"+position+" is clicked ",
                      Toast.LENGTH_SHORT).show();

            return false;
        }
      });

    //setListAdapter(notes);
    setListAdapter(notes);

我有它都有一个复选框以及列表行自定义布局。我怎样才能创建的复选​​框事件的侦听器?我已搜查,并听取了有关bindView但是否有任何人能多一点解释清楚? <一href=\"http://stackoverflow.com/questions/4702877/update-a-checkbox-in-listview-row-that-corresponds-to-a-database-row\">this是链接有人解释,但我不能在我的code插入。

I have a custom layout for the list row which has a checkbox as well. How can I create a listener for the checkbox event? I have searched and heard about bindView but is there anyone can explain it a bit more clearly? this is the link someone explained it but I couldnt plug it in my code.

推荐答案

下面就是答案从这个链接 我想通了这一点。它解释得很清楚。谢谢大家。

Here is the answer After reading from this link I figured that out. It explains it very clearly. Thanks to everyone.

这篇关于如何监听在ListView行中的复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆