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

  • Home
  • SEARCH
  • 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 8343671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:08:14+00:00 2026-06-09T06:08:14+00:00

I have created a listview which displays the installed applications. It has app icon

  • 0

I have created a listview which displays the installed applications. It has app icon + app name + check box. I want to select apps from this list and store the app names in a sqlite DB how should I begin with this?

Like how to identify the selected apps?

  • 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-09T06:08:16+00:00Added an answer on June 9, 2026 at 6:08 am

    here’s an adapter I made for one of my apps. This is a classroom attendance function that shows the student’s name, photo and a couple of checkboxes (one for here, for for late). The list comes from a SQlite query, but I need to do something with each checkbox that is clicked.

    public class MyDataAdapter extends SimpleCursorAdapter {
        private Cursor c;
        private Context context;
        private Long classnum;
        private gradeBookDbAdapter mDbHelper;
    
        public static final int LATE=2;
        public static final int ATTEND=1;
        int idxCol;
        int idx;
    
        // itemChecked will store the position of the checked items.
    
        public MyDataAdapter(Context context, int layout, Cursor c, String[] from,
                int[] to, Long mRowId) {
            super(context, layout, c, from, to);
            this.c = c;
            this.context = context;
            mDbHelper = new gradeBookDbAdapter(context);
            mDbHelper.open();
            classnum = mRowId;
            c.moveToFirst();
    
    
    
        }
        public class ViewHolder{
            public TextView text;
            public TextView text2;
            public ImageView image;
            public CheckBox here;
            public CheckBox late;
        }
    
    
        public View getView(final int pos, View inView, ViewGroup parent) {
            Bitmap bm;
            ImageView studentPhoto;
            View vi=inView;
            final ViewHolder holder;
    
            if (inView == null) {
                LayoutInflater inflater = (LayoutInflater) context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                vi = inflater.inflate(R.layout.show_attendance, null);
    
                holder=new ViewHolder();
                holder.text=(TextView)vi.findViewById(R.id.stuname);
                holder.text2=(TextView)vi.findViewById(R.id.stuIndex);
                holder.image=(ImageView)vi.findViewById(R.id.icon);
                holder.here=(CheckBox)vi.findViewById(R.id.attend);
                holder.late=(CheckBox)vi.findViewById(R.id.late);
                vi.setTag(holder);
    
            }
            else
               holder=(ViewHolder)vi.getTag();
    
    
            c.moveToPosition(pos);
            int index = c.getColumnIndex(gradeBookDbAdapter.KEY_NAME);
            String name = c.getString(index);
            holder.text.setText(name);
            index = c.getColumnIndex(gradeBookDbAdapter.KEY_ROWID); 
            String Index = c.getString(index);
            holder.text2.setText(Index);
    
            bm = gradeBookDbAdapter.getStudentPhoto(name);
            if (bm != null) {
                holder.image.setImageBitmap(bm);  
            }           
            else {
                // use icon image
                holder.image.setImageResource(R.drawable.person_icon);
            }
    
    
            // pull out existing attend/late fields and set accordingly
            int attend = c.getInt(c.getColumnIndex(gradeBookDbAdapter.KEY_ATTEND));
            if(attend==1){
               holder.here.setChecked(true);
               itemCheckedHere.set(pos, true);
            }
            //else {
            //   holder.here.setChecked(false);
            //   itemCheckedHere.set(pos, false);
            //}
    
            int late = c.getInt(c.getColumnIndex(gradeBookDbAdapter.KEY_LATE));
            if (late==1){
               holder.late.setChecked(true);
               itemCheckedLate.set(pos, true);
            }
            //else {
            //  holder.late.setChecked(false);
            //    itemCheckedLate.set(pos, false);
            //}
    
    
    
    
            holder.here.setOnClickListener(new OnClickListener() {
    
                public void onClick(View v) {
    
                    CheckBox cb = (CheckBox) v.findViewById(R.id.attend);
    
                    if (cb.isChecked()) {
                        itemCheckedHere.set(pos, true); 
                        int Index = new Integer(holder.text2.getText().toString());
                        mDbHelper.updateAttend(Index, classnum, ATTEND, 1, attendDate ); 
                    } else if (!cb.isChecked()) {
                        itemCheckedHere.set(pos, false);
                        int Index = new Integer(holder.text2.getText().toString());
                        mDbHelper.updateAttend(Index, classnum, ATTEND, 0, attendDate );
                    }
                }
            });
            holder.late.setOnClickListener(new OnClickListener() {
    
               public void onClick(View v) {
                    CheckBox cb = (CheckBox) v.findViewById(R.id.late);
    
                    if (cb.isChecked()) {
                       itemCheckedLate.set(pos, true);
                       int Index = new Integer(holder.text2.getText().toString());
                       mDbHelper.updateAttend(Index, classnum, LATE, 1, attendDate );
                    } else if (!cb.isChecked()) {
                       itemCheckedLate.set(pos, false);
                       int Index = new Integer(holder.text2.getText().toString());
                       mDbHelper.updateAttend(Index, classnum, LATE, 0, attendDate );
                    }
                }
            });
    
    
            holder.here.setChecked(itemCheckedHere.get(pos)); // this will Check or Uncheck the
            holder.late.setChecked(itemCheckedLate.get(pos)); // this will Check or Uncheck the
            // CheckBox in ListView
            // according to their original
            // position and CheckBox never
            // loss his State when you
            // Scroll the List Items.
    
            return vi;
        }
    
    }
    

    Notice I have two sparse arrays “ItemCheckedHere’ and “ItemCheckLate”. these keep track of which items I’ve selected. Android doesn’t keep track and will reuse a view, so scrolling a list of checkboxes will result in boxes getting checked or unchecked seemingly at random without these arrays I use to maintain the checked status.

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

Sidebar

Related Questions

I have created a listview which displays all the people in the database. But
I have a listview with several items that are created dynamically, each has two
I have a listview, which displays a list of administrators, this list is held
I have created a custom tab layout which look like this,I want to make
I have a list (ListView) which which displays a lot of information, and what
I have a ListView which I've created a custom view for each row. My
I have created an app in which I had use SPenSDK to create image
I've created a model which displays list of checkable strings in a listView. I
I have been trying to create a ListView which I can sort using drag
I have created a listview with 3 rows in Android. If I would like

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.