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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:22:03+00:00 2026-06-01T13:22:03+00:00

I am using listview to display three textviews(values for these text views where come

  • 0

I am using listview to display three textviews(values for these text views where come from database) and one checkbox. I would like to store the checkbox state when ever the user clicks the checkbox and display it when they came back. But, i am new to android development and i haven’t got any idea how to do it. I have tried adding checkbox to the list view, but the onitemclick is disabled.Below are the code,

This is the cursor to retrieve values from database and list in listview,

Cursor yearcursor = db.paymentall(this); 
 String[] yearfrom = new String[]  
{ PaymentAppDataBase.REQUESTEDDATE,PaymentAppDataBase.PAYMENTNAME,PaymentAppDataBase.AMOUNT };
 int[] yearto = new int[] { R.id.Date,R.id.Name,R.id.Amount };

            SimpleCursorAdapter yearadapter =

 new SimpleCursorAdapter(this, R.layout.listview, yearcursor, yearfrom, yearto);

setListAdapter(yearadapter);

 amount.setOnItemClickListener(new OnItemClickListener() {


@Override

public void onItemClick(AdapterView<?> parent, View view, int position,

 long id) {


 Cursor cursor = (Cursor) parent.getItemAtPosition(position);


 String toaddressreview = cursor.getString(4);

 String subjectreview = cursor.getString(5);

 String emailbodyreview = cursor.getString(6);

 Intent todayreview = new Intent(ReviewPayment.this,ReviewandResend.class);

todayreview.putExtra("toadd", toaddressreview);

 todayreview.putExtra("subjectreveiew", subjectreview);

 todayreview.putExtra("emailbody", emailbodyreview);

 startActivity(todayreview);

 }

}); 

Mt xml file:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:paddingTop="4dip"

android:paddingBottom="6dip"

 android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:orientation="horizontal">


 <TextView android:id="@+id/Date"

 android:layout_width="100dip"

 android:layout_height="wrap_content"

 android:textSize="14sp"/>


<TextView android:id="@+id/Name"

 android:layout_width="120dip"

android:layout_height="wrap_content" 

android:layout_weight="2" 

 android:scrollbarAlwaysDrawHorizontalTrack="true"

 android:layout_toRightOf="@+id/Date"/>


<TextView android:id="@+id/Amount"

 android:layout_width="50dip"

android:layout_height="20dip"  

 android:scrollbarAlwaysDrawHorizontalTrack="true" 

 android:layout_weight="2"

 android:layout_toRightOf="@+id/Name"/>


<CheckBox

 android:id="@+id/checkBox1"

 android:layout_width="wrap_content"

 android:layout_height="50dip"

 android:layout_alignBottom="@+id/Amount"

 android:layout_alignParentRight="true"

 android:layout_toRightOf="@+id/Amount" />

</RelativeLayout>

It would be great if i get the answer for two questions,

1. How to save the state of the checkbox?

2. How to enable onitemclicklistener while using checkbox?

Thanks in advance

  • 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-01T13:22:04+00:00Added an answer on June 1, 2026 at 1:22 pm
    1. There is no easy way but to keep an array of boolean equal to the number of your list items and store the state. You need to make this a member variable of the custom adapter that you derive from your SimpleCursorAdapter.

    2. Again, it needs to be part of your custom adapter. In your getView() function of the adapter, you need to implement the onCheckedChangeListener() [don’t recall the exact name right now] for the checkbox and in your main Activity where you have the listview, set the onItemClickListener() to the listview.

    If this doesn’t make sense, just go through a bit in stackoverflow. This question has been dealt with numerous times.

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

Sidebar

Related Questions

I have a ListView which is using a GridView to display a DataTable and
I am using ListView/DataPager. For performance reasons I page my results at database, using
I am using three buttons along with the list view.These three buttons are added
I need to display results from a SQL join in a ListView/ListActivity. I've created
I am using listview to display data, inside listview i am using image in
I'm using a ListView control in virtual and OwnerDraw mode to display a number
I am wanting to display a text field stating that my listview is empty
I have ObservableCollection for my Collection og Movie files. Im using ListView to display
i want to display some information in a listview using the GridView. i have
i am using a viewholder to display from a dynamic arrayadapter.it works but the

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.