i am creating checkbox dynamically from a list ,now how to check user selected which checkbox from a list in android
for (int i = 0; i < languageList.size(); i++) {
HashMap<String, String> item_hash = new HashMap<String, String>();
String lang = languageList.get(i).getLanguage();
final String langId = languageList.get(i).getLanguageId();
item_hash.put(langId, lang);
ar[i] = langId;
// String langId = languageList.get(i).getLanguage_id();
item_list1.add(item_hash);
cb = new CheckBox(parentActivity);
cb.setText(languageList.get(i).getLanguage().toString());
cb.setId(Integer.parseInt(languageList.get(i).getLanguageId()));
Button btnSubmit = (Button) findViewById(R.id.btn_submit);
// show location button click event
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if(cb.isChecked()){
System.out.println("id "+cb.getText()+langId);
}
}
});
Aucun commentaire:
Enregistrer un commentaire