I am working on a an Android Application . i have created some toggle buttons dynamically and they are clickable too...
what i want to achieve is toggle on any specific button and its ok. but when i toggle on any other button all other toggle button should go off..
like i can toggle on any one button at a time . if any other pressed on the previous one should go off.
there are dynamic number of buttons ..
and i dont know how to achieve this .
here is my code :
for ( int i = 0; i<sez; i++ ){
final ToggleButton btn = new ToggleButton(xxxxx.this);
String g = contactList.get(i).toString();
Pattern p = Pattern.compile("\\{([^}]*)\\}");
Matcher m = p.matcher(g);
while (m.find()) {
String[] po=m.group(1).split("=");
btn.setId(i);
btn.setTextOn("play");
btn.setText(po[1]);
btn.setTextOff(po[1]);
final int id_ = btn.getId();
Rowlayout layout = (org.xxxx.xxx.ui.Rowlayout) findViewById(R.id.adios);
layout.addView(btn);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Toast.makeText(InCallScreen.this,
list2.get(id_) + "", Toast.LENGTH_SHORT).show();
}
});
}
}
i have spent 3 days on it but still stuck in it, any one can help me . it will be much appreciated....