samedi 12 août 2017

programatically dynamic views

my naswer is very short and simple: im consuming a a service, it get me data via JSON. The data from webservice is a String (letters separated with comma like A,B,C,D).Now...y split the String and generate an array String[] from the JSON data (String []=..{A,B,C,D}). Them i need to generate checkboxes(one per letter in the array..those values are dynamic, array can get a variable numbers of letters) and i need to take control of ich one (y need take). i need to download a file (one fipe per checked checkbox) from server,and i cant (and dont know) get reference for each checkbox to know wich file download

heare is the logic im use to generate checks

 for(String a: recorridos)
            {
                CheckBox ch = new CheckBox(this);
                ch.setText("recorrido "+a,null);

                checkoxes.addView(ch);

            }

the problem of these way: im dont know the id from each check, and cant know if is checked or not i need to set a different id from each check to get status(ischecked)? exis another way to do it more functionally or simple?




Aucun commentaire:

Enregistrer un commentaire