Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Problem with AlertDialog.Builder and Checkboxes

Problem with AlertDialog.Builder and Checkboxes

Put your problem here if it does not fit any of the other categories.

Problem with AlertDialog.Builder and Checkboxes

Postby JoxTraex » Wed Mar 09, 2011 3:22 am

Hello All, I've been working on this application but have come across a problem that I have been unable to figure out. I have a listview that is populated with the contents from an adapter, and each row has their specific information (Uniform). The problem comes when I try to retrieve the value of a checkbox that is found in that particular row.

The code in question is below:

I build an AlertDialog object so I can get my information from the user. My layout code consists of a LinearLayout in horizontal orientation with 3 elements an image, text, check box. I build my AlertDialog with R.layout.listview_layout, which is a custom layout that I made.

One thing I tried to do is get the CheckBox View from the adapter, however; when I look at it via cb.isChecked(), no matter what row i'm on its always unchecked (aka false). In order to debug this further I took the same adapter and retrieved the text via the same methodology and it returned specific information about that row, as it should.

Any ideas how I can handle this?

Simply Put:

I would just like to get the value of the CheckBox at each given row

Code: Select all
c = help.returnContacts();

     AlertDialog.Builder ab = new AlertDialog.Builder(this);
    ab.setTitle("Select contacts");

    final SimpleCursorAdapter adapter = new SimpleCursorAdapter(
            getApplicationContext(), R.layout.listview_layout, c,
            new String[] { ClientOpenDbHelperUtility.COL_NAME,
                    ClientOpenDbHelperUtility.COL_SEL }, new int[] {
                    R.id.txt_name, R.id.cb_select });
    ab.setAdapter(adapter, null);

    ab.setPositiveButton("Confirm", new Dialog.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {

            Cursor c = adapter.getCursor();
            for (int i = 0; i < adapter.getCount(); i++) {

                CheckBox cb = (CheckBox) adapter.getView(i, null, null)
                        .findViewById(R.id.cb_select);
                TextView t = (TextView) adapter.getView(i, null, null)
                        .findViewById(R.id.txt_name);

                Log.d("DEBUG", "Checked = " + cb.isChecked());
                Log.d("DEBUG", "Message = " + t.getText().toString());
                if (cb.isChecked()) {

                    help
                            .updateSelection(
                                    c
                                            .getColumnIndex(ClientOpenDbHelperUtility.COL_UID),
                                    true);
                } else {
                    help
                            .updateSelection(
                                    c
                                            .getColumnIndex(ClientOpenDbHelperUtility.COL_UID),
                                    false);
                }

            }
            c.close();
            help.closeAll();

        }

    });
    ab.show();

}


Thanks for reading!
JoxTraex
Developer
Developer
 
Posts: 25
Joined: Wed Jan 26, 2011 12:29 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 9 guests