チェックボックス付きのリストがあり、保存とクリアの 2 つのボタンがあります。クリアボタンをクリックしたときにチェックボックスをオフにする方法、
public class myProfileActivity extends Activity {
private List<Profile> contacts = null;
private String TAG = "ContactListActivity";
private String inputName;
ListView lvContact;
private Activity _activity;
private ListView mainListView;
private Profile[] itemss;
private ArrayAdapter<Profile> listAdapter;
ArrayList<String> checked = new ArrayList<String>();
public static List<AttractionData> selectedData = new ArrayList<AttractionData>();
private String profileType = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
ContentResolver cr = this.getContentResolver();
setContentView(R.layout.profilelist);
_activity = this;
profileType = getIntent().getExtras().getString("ProfileType");
try {
if (Constants.loadEntries != null) {
Constants.loadEntries.cancel(true);
}
} catch (Exception e) {
Log.e(TAG, "Loading Data------", e);
}
Constants.loadEntries = new LoadEntries();
Constants.loadEntries.execute();
EditText editTxt = (EditText) findViewById(R.id.txtContName);
editTxt.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void afterTextChanged(Editable s) {
inputName = s.toString();
Log.d(TAG, "LoadMoreEntries --> Constants.loadEntries : "
+ Constants.loadEntries);
try {
if (Constants.loadEntries != null) {
Constants.loadEntries.cancel(true);
}
} catch (Exception e) {
Log.e(TAG, "Loading Data--------", e);
}
Constants.loadEntries = new LoadEntries();
Constants.loadEntries.execute();
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
}
});
Button clearbtn = (Button) findViewById(R.id.clearbtn);
clearbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
Button savebtn = (Button) findViewById(R.id.savebtn);
savebtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (Constants.selectedContacts.size() > 0) {
((CityPreferences) ProfileActivity.this.getApplication())
.storeAllContacts(Constants.selectedContacts);
Constants.selectedContacts= new ArrayList<Profile>();
finish();
v.getContext().startActivity(
new Intent(v.getContext(), PalABActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
});
}
どんな助けでも大歓迎です。