This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Android and the fly likes Problems with listview and checkbox event Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Mobile » Android
Reply Bookmark "Problems with listview and checkbox event" Watch "Problems with listview and checkbox event" New topic
Author

Problems with listview and checkbox event

Jack Alex
Greenhorn

Joined: Mar 19, 2012
Posts: 5
I'm having problems with what's suppose to be a simple thing to code. I create a list view with two columns: a checkbox and a text view. When the user clicks on the text view, I fire up an intent and when the user clicks on the checkbox (one or more of them) I want to grab the id and show a 'delete this textview' icon in the action bar. I don't understand how to listen for the event when the users checks a checkbox.

This sums up what I'm trying to accomplish


This is my main.xml which contains the List View:


The custom layout which is used to display the checkbox and the textview in the listview (msg.xml):


Main class:


If anyone can help I would be very grateful, I've been struggling with this for 2 days now.
Mohan Prasath
Ranch Hand

Joined: Jul 25, 2011
Posts: 38

The following code is a sample for CheckBox on Checked Event.

CheckBox box = (CheckBox) findViewById(R.id.checkBox1);
box.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
// Your Logic here
}
}
});


Is this what you are looking for ?.


With regards,
Mohan Prasath
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with listview and checkbox event
 
Similar Threads
How to get View from customised ListView?
How to show Arraylist object values in proper table format in android
Multiple Checkboxes in ListView
Layouts, bottom position
How to show a title to a ListView