Hello!
Im using a custom listView with a Title and a Subtitle where you can read a brief explanation of the item.
For each item on the list, im displaying an alertDialog to select an option (different for each case). When the option is selected, i want to change the Subtitle for the option selected by the user.
This is what i tried:
listview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch(position){
case 0: final CharSequence[] alertText1 = {"Area 1", "Area 2", "Area 3"};
ventana.setTitle("Choose an Area");
ventana.setItems(alertText1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
TextView subTitulo = (TextView) findViewById(R.id.subTitulo);
subTitulo.setText(alertText1[item]);
}
});
ventana.show();
break;
case 1: final CharSequence[] alertText2 = {"1", "2", "3", "5", "10", "20", "60"};
ventana.setTitle("Max. duration");
ventana.setItems(alertText2, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
TextView subTitulo = (TextView) findViewById(R.id.subTitulo);
subTitulo.setText(alertText2[item]);
}
});
ventana.show();
break;
case 2: final CharSequence[] alertText3 = {"3", "5", "10", "20", "30", "60"};
ventana.setTitle("Time between events");
ventana.setItems(alertText3, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
TextView subTitulo = (TextView) findViewById(R.id.subTitulo);
subTitulo.setText(alertText3[item]);
}
});
ventana.show();
break;
For the first item on the list it works fine, when i select an option, the subtitle get replaced by that option, but when i make a selection in the alertDialogs of the other 2 items, the option selected replaces the subtitle of the first item!
Any idea of how can i fix that?