private void createComboBox(Gene root, LinearLayout view) { this.layoutAux = view; final ComboCodon codon = (ComboCodon) root.getCodon(); TextView label = new TextView(this.context); LayoutParams params = new LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, codon.getWeight()); label.setText(codon.getText()); this.layoutAux.addView(label, params); final SmartObjectGUIActivity activity = (SmartObjectGUIActivity) this.context; BlockingOnUIRunnable actionRunnable = new BlockingOnUIRunnable( activity, new IBlockingOnUIRunnableListener() { public void runOnUIThread() { LayoutParams params = new LayoutParams( 0, LinearLayout.LayoutParams.WRAP_CONTENT, 1 - codon.getWeight()); ArrayAdapter<String> adapter = new ArrayAdapter<String>( activity, android.R.layout.simple_spinner_item, codon.getOptions()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Spinner spinner = new Spinner(activity); spinner.setAdapter(adapter); layoutAux.addView(spinner, params); } }); actionRunnable.startOnUiAndWait(); }
private void createRadioButton(Gene root, LinearLayout view) { this.layoutAux = view; final ComboCodon codon = (ComboCodon) root.getCodon(); TextView label = new TextView(this.context); LayoutParams params = new LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, codon.getWeight()); label.setText(codon.getText()); this.layoutAux.addView(label, params); final SmartObjectGUIActivity activity = (SmartObjectGUIActivity) this.context; BlockingOnUIRunnable actionRunnable = new BlockingOnUIRunnable( activity, new IBlockingOnUIRunnableListener() { public void runOnUIThread() { RadioGroup group = new RadioGroup(activity); group.setOrientation(RadioGroup.VERTICAL); for (String option : codon.getOptions()) { RadioButton rb = new RadioButton(activity); rb.setText(option); group.addView(rb); } ((RadioButton) group.getChildAt(0)).setChecked(true); LayoutParams params = new LayoutParams( 0, LinearLayout.LayoutParams.WRAP_CONTENT, 1 - codon.getWeight()); layoutAux.addView(group, params); } }); actionRunnable.startOnUiAndWait(); }