jeudi 18 juillet 2019

setOnItemClickListener cannot modifie template's checkbox

I'm working on a program in which I need to check some items. For that, I created a listView, an adapter and a template (XML of the adapter). The template contains text and a checkbox then in my activity I can see each item with it's name and the checkbox. I have to manage the number of items checked and then I tried to do this with setOnItemClickListener, but it doesn't works...

I looked around the web, but nobody got this problem, then I think that I'm doing it the wrong way, or nobody needed it ?

Here's my setOnItemClickListener :

m_listViewConcepts.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
                CheckBox checkBox = view.findViewById(R.id.checkbox_pick_concepts);
                if (!checkBox.isChecked() && m_conceptCount < m_maxFrames) {
                    checkBox.setChecked(true);
                    m_conceptCount++;
                    m_textViewConceptsCount.setText(String.format(getResources().getString(R.string.concept_count), m_conceptCount, m_maxFrames));
                } else {
                    checkBox.setChecked(false);
                    m_conceptCount--;
                    m_textViewConceptsCount.setText(String.format(getResources().getString(R.string.concept_count), m_conceptCount, m_maxFrames));
                }
            }
        });

It doesn't even can be clicked... If you have a lead or something it could help me a lot !




Aucun commentaire:

Enregistrer un commentaire