0
我知道這個問題很熟悉,但我需要幫助。我不知道爲什麼我的代碼返回空指針。在這裏,我走到這一步:如何使用其他複選框或按鈕檢查gridview中的所有複選框
final GridView imagegrid = (GridView) findViewById(R.id.grid_GalleryImage);
imageAdapter = new ImageAdapter();
imagegrid.setAdapter(imageAdapter);
// Check All
Button btnCheckAll = (Button) findViewById(R.id.btn_SelectAll);
btnCheckAll.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
int count = imagegrid.getAdapter().getCount();
for (int i = 0; i < count; i++) {
LinearLayout itemLayout = (LinearLayout)imagegrid.getChildAt(i); // Find by under LinearLayout
CheckBox checkbox = (CheckBox)itemLayout.findViewById(R.id.cbo_CheckImage);
checkbox.setChecked(true);
}
}
});