Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7843703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:38:05+00:00 2026-06-02T16:38:05+00:00

My custom adapter in activity: private static HashMap<Integer, Boolean> checkedMap; private class MyMediaCursorAdapter extends

  • 0

My custom adapter in activity:

private static HashMap<Integer, Boolean> checkedMap;

private class MyMediaCursorAdapter extends ResourceCursorAdapter {

    public MyMediaCursorAdapter(Context context, int layout, Cursor c) {
        super(context, layout, c);

    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        View view = super.newView(context, cursor, parent);
        final RecordListItemCache cache = new RecordListItemCache();

        cache.date = (TextView)view.findViewById(R.id.dateRecorded);
        cache.checkBox = (CheckBox)view.findViewById(R.id.checkBoxView);    

        view.setTag(cache);         
        return view;
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        final RecordListItemCache cache = (RecordListItemCache)view.getTag();

        final SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
        final String dateString = sdf.format(cursor.getLong(cursor
                .getColumnIndex(MediaStore.Audio.Media.DATE_ADDED))*1000);

        final String displayName = cursor.getString(cursor
                .getColumnIndex(MediaStore.Audio.Media.TITLE));

        final int id = cursor.getInt(cursor
                .getColumnIndex(MediaStore.Audio.Media._ID));
        cache.checkBox.setOnCheckedChangeListener(null);
        Boolean chk = checkedMap.get(id);
        if (chk==null) {
            cache.checkBox.setChecked(false);
        } else {
            cache.checkBox.setChecked(chk);
        }


        cache.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                checkedMap.put(id, isChecked);

            }
        });

        cache.checkBox.setText(displayName);
        cache.date.setText(dateString);
    }   
}

final static class RecordListItemCache {
    public CheckBox checkBox;
    public TextView date;
    public boolean checked;
}

In onCreate in the same activity:

myMediaCursorAdapter = new MyMediaCursorAdapter(getApplicationContext(),
            R.layout.multipledeleteview, audioCurosr);
setListAdapter(myMediaCursorAdapter);

And onClick:

public void onClick(View button) {
    switch (button.getId()) {
        case R.id.buttonDeleteMultiple: {
            Collection<Integer> IDs = checkedMap.keySet();
            for (Integer id : IDs) {
                if (checkedMap.get(id)==true) {
                    RecorderUtils.delete(getApplicationContext(), id, false);
                }
            }
            checkedMap = new HashMap<Integer, Boolean>();
        }
        case R.id.buttonDeleteMultipleChooseAll: {
            int size = myMediaCursorAdapter.getCount();
            ListView lv = getListView();
            for(int i = 0; i <= size; i++) {
                lv.setItemChecked(i, true);
            }
            myMediaCursorAdapter.notifyDataSetChanged();
        }
    }
}

Delete is working fine (it deletes checked-ones). But button for choosing all doesn’t change anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:38:06+00:00Added an answer on June 2, 2026 at 4:38 pm

    I reload the view with checked checkboxes…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview with a custom array adapter: public class SmsMessageAdapter extends ArrayAdapter<ContactMessage>
I have made a custom adapter class here is the code public class CustomArrayAdapterForReceipts
I have the following class in my program: public class RZoom extends Activity {
I have list activity with custom array adapter and I can't to get context
Here is a short List activity that calls a custom adapter to show class
I have a ListView with a custom Adapter that extends ArrayAdapter. It's a ArrayAdapter
I have a ListView with a custom list adapter (that extends BaseAdapter). My list
I have a custom ListView adapter which implements an ImageThreadLoader class. Unfortunately, the class
I am using a custom Adapter class. And retrieving data from database using cursor.
I have an activity with listview and attached footer. I created my custom adapter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.