Created
April 13, 2014 17:06
-
-
Save codeguru42/10592863 to your computer and use it in GitHub Desktop.
onResume()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onResume() { | |
super.onResume(); | |
// restore default header state | |
CheckedTextView headerCheck = (CheckedTextView) this.headerView | |
.findViewById(R.id.checkmark); | |
headerCheck.setChecked(false); | |
boolean[] newSelection = new boolean[this.adapter.getCount()]; | |
if (this.savedSelection != null) { | |
// copy old selection array into new selection array | |
int numSelected = 0; | |
for (int i = 0; i < this.savedSelection.length; i++) { | |
newSelection[i] = this.savedSelection[i]; | |
if (newSelection[i]) { | |
numSelected++; | |
} | |
View row = this.listView.getChildAt(i + 1); | |
if (row != null) { | |
CheckedTextView checkbox = (CheckedTextView) row | |
.findViewById(R.id.checkmark); | |
checkbox.setChecked(newSelection[i]); | |
TextView playerText = (TextView) row | |
.findViewById(R.id.player_name_text_view); | |
Log.d(TAG, playerText.getText().toString() + " checked? " | |
+ checkbox.isChecked()); | |
} | |
} | |
// restore header state | |
if (numSelected == newSelection.length) { | |
headerCheck.setChecked(true); | |
} | |
} | |
// restore state | |
this.adapter.setSelection(newSelection); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment