android


only first element in checkbox is selected i need select all item on listview


here is my code for check all items on listview. only first element in checkbox is selected i need select all item on listview
public void onCheckedChanged( Compound Button button View, boolean is Checked) {
Check Box c b=(Check Box)find View By Id(R.id. c b List_hook);
Text View ex=(Text View) find View By Id(R.id.t v list_name);
if(is Checked)
{
for(integer I =1; I<=l v. get Child Count();I++)
{
l v. set Item Checked(I,true);
test.add(ex . get Text().to String());
}
}
if(!is Checked)
{
for(integer I=1;I<=l v. get Child Count();I++)
{
l v. set Item Checked(I,false);
test.remove(ex . get Text(). to String());
}
}
}
}
Try This:
private ArrayList<Getter_Setter> user_list;
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
for (int i = 0; i < user_list.size(); i++) {
user_list.get(i).setSelected(checkbox.isChecked());
}
adapter.notifyDataSetChanged();
}
});
Getter_Setter Class:
private boolean Selected = false;
public boolean isSelected() {
return Selected;
}
public void setSelected(boolean selected) {
Selected = selected;
}
Adapter Class:
mHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int getPosition = (Integer) buttonView.getTag();
user_info_list.get(getPosition).setSelected((isChecked));
}
});

Related Links

Using tabs in Android
Android - OAuth app with popupWindow
Android: code acts crazy
Android ListView Adapter shows only last element
Android wrong action loads
android how can i close a SlidingDrawer that was opened manually
Android Saving an image on the device
Multicast Support on Android in Hotspot/Tethering mode
Which listener gets triggered when the mapview's dimensions change from their initial (zero) state?
Android: Can I have a mixed format text in TextView
How to Make a Custom Overlay View Transparent on top of a SurfaceView?
Using bluetooth framework in Android SDK slows down the system extremely while uninstalling the app
Android: ImageSwitcher inside Scrollview places image at bottom of the screen
How to create a Fragment loading information from SQLDatabase?
Exception when creating a simple, two-pane layout with fragments
Android - Refresh main content only

Categories

HOME
batch-file
httparty
delphi-7
deep-learning
c++11
redux-form
serialization
spring-data-mongodb
rom
parameters
ado.net
zip
android-json
azure-container-service
nstableheaderview
modal-dialog
okhttp
alamofire
shared-libraries
plink
package-managers
linear-algebra
entitymanager
scsi
jmp
windows-xp
poedit
href
react-toolbox
8051
inversion-of-control
iis-express
uitapgesturerecognizer
ntp
livelink
scatter3d
angularjs-material
sammy.js
keras-layer
magento-1.9.2.4
tex
diacritics
metawidget
doc
vaadin-charts
facebook-social-plugins
spring-data-couchbase
reshape
ampps
javafx-css
node-request
actor-platform
dotnetnuke-7
watch-os-2
mta
cifilter
android-dateutils
eigenvector
hadoop-partitioning
upx
libvlc
opl
avisynth
pax-exam
cgi-bin
google-refine
phpldapadmin
showdialog
rickshaw
with-statement
windows-phone-8-sdk
ice-cube
gpars
workitem
route-provider
octal
cascadingdropdown
fb.ui
nokia-s40
wcf-configuration
box2d-iphone
pinch
htdocs
filemerge
lr
jqote
uipagecontrol
codebase
nhprof
squishit
updatesourcetrigger
sifr3
fault-tolerance
firefox-3
pbcopy
blind

Resources

Encrypt Message