i'm currently coding an app, which has to add/remove interface elements on the fly. When one clicks on a Spinneritem, the selected item is added to a container with a delete button to remove it if necessary.
The problem is, that the needed views and the layout are created directly in the javacode using this code:
Using java Syntax Highlighting
- LinearLayout layout = new LinearLayout(MainActivity.this);
- TextView newTag = new TextView(MainActivity.this);
- newTag.setText(tags.get((int) rowid));
- Button delButton = new Button(MainActivity.this);
- delButton.append("X");
- layout.addView(newTag);
- layout.addView(delButton);
- tagContainer.addView(layout);
Parsed in 0.015 seconds, using GeSHi 1.0.8.4
I'm now wondering how it is possible to add layoutparams to the new views like in an xml file (android:width="fill_parent" etc.) or if it is not the better way to read this layoutpart from an xml and change only the needed parameters. And if yes, how to do it (both ways).
thx