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 8839617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:16:34+00:00 2026-06-14T10:16:34+00:00

I have implemented one custom adapter for my list view having checkbox and text

  • 0

I have implemented one custom adapter for my list view having checkbox and text item. I can get the position through my overridden parameter. but how to get the id of my list row ?

following is code for custom adapter –

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View rowView = convertView;
        if (rowView == null) {
            LayoutInflater inflater = context.getLayoutInflater();
            rowView = inflater.inflate(R.layout.reminder_row, null);
            ViewHolder viewHolder = new ViewHolder();
            viewHolder.text = (TextView) rowView.findViewById(R.id.reminderRowTextId);
            viewHolder.reminderCheckBox = (CheckBox) rowView.findViewById(R.id.CheckBoxId);
            rowView.setTag(viewHolder);
        }

        final int pos = position;
        final ViewHolder holder = (ViewHolder) rowView.getTag();
        int idRow = holder.text.getId();
        Log.i(TAG, "id of item selected-->" + idRow); <<<<<<------- IT IS GIVING SOME VALUE LIKE 2030771-------->>>
        String s = names[position];
        holder.text.setText(s);

        holder.reminderCheckBox.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (holder.reminderCheckBox.isChecked()) {
                    Toast.makeText(getContext(), "pos-->chkd" + pos, Toast.LENGTH_SHORT).show();
                    long longPos = (long)pos;
                    dbHelper.completeTask(longPos + 1);

                } else {
                    Toast.makeText(getContext(), "pos-->un--chkd" + pos, Toast.LENGTH_SHORT).show();
                }
            }
        });

        holder.text.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Toast.makeText(getContext(), "TEXT CLICKED" + pos , Toast.LENGTH_SHORT).show();

                Intent intent = new Intent(context,ReminderModificationActivity.class);
                long longPos = (long)pos;
                intent.putExtra(TasksDBAdapter.KEY_ROWID, longPos + 1);
                Log.i(TAG, "row clickd --> " + longPos);
                ((Activity) context).startActivityForResult(intent, ACTIVITY_EDIT);
            }
        });
        return rowView;
    }

EDIT 1.1

public static final String KEY_TITLE = "title";                  
    public static final String KEY_BODY = "body";
    public static final String KEY_DATE_TIME = "reminder_date_time"; 
    public static final String KEY_ROWID = "_id";                
    public static final String KEY_IS_COMPLETE = "is_complete";
    private static final String TAG = "TasksDBAdapter";

private static final String DATABASE_CREATE =                        
           "create table " + DATABASE_TABLE + " ("
                   + KEY_ROWID + " integer primary key autoincrement, "
                   + KEY_IS_COMPLETE + " boolean default 'false', "
                   + KEY_TITLE + " text not null, " 
                   + KEY_BODY + " text , " 
                   + KEY_DATE_TIME + " text);"; 

Please have a look at marked line. Can anyone please help me with how to get the id. Please be detailed as I m learning android.
Thanks in advance,
Ray

  • 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-14T10:16:35+00:00Added an answer on June 14, 2026 at 10:16 am

    You’re calling getId() on a TextView, which according to the docs returns the value associated with the android:id attribute. This value is auto generated, and is probably the same as R.id.reminderRowTextId.

    Basically, you’re not actually setting a meaningful ID in your ViewHolder class. Just add another member variable, and store whatever you need.

    To elaborate, an adapter is used to describe the size of a backing list/array, and provide a View for each element. To do this properly, you implement getView() and getItem().

    getItem() takes a position, which is a parameter to getView(). Pass in position to getItem(), which will give you your item from SQLite. Get that object’s ID, and set a variable in ViewHolder.

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

Sidebar

Related Questions

I have a list view with custom adapter. I'm trying to implement following when
I have implemented horizontal page view. One base page and three swipe pages. The
I currently have a custom listview with two rows of text in each item,
I have a AutoCompleteTextView and a custom AutoCompleteTextView adapter. my list has 20 items
I have implemented a custom split view controller which — in principle — works
I want to send to adapter only one item from my custom ArrayList. When
I have a list view with several ToggleButton items. When I click one, another
I have implemented a gridview with custom adapter and the adapter inflates a layout
I have implemented one matrix multiplication with boost::numeric::ublas::matrix (see my full, working boost code
I have implemented onRetainNonConfigurationInstance() on one of my Activity to handle android screen orientation.

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.