creating dynamic xml in android

Wxxvsdkkqgncx

New Member
In my app I want the xml to be created dynamically because depending on some input data I want different elements. So I started with this example, to create a simple dynamic xml of a TextView and a Spinner. The problem is that I do not see anything in the emulator.Here is my code:\[code\] public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout top = new LinearLayout(this); top.setOrientation(LinearLayout.VERTICAL); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.HORIZONTAL); top.addView(ll); TextView tv = new TextView(this); tv.setText("Dynamic layouts ftw!"); ll.addView(tv); String signs[]={"+","-"}; Spinner spinner = new Spinner(this); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, signs); spinner.setAdapter(spinnerArrayAdapter); ll.addView(spinner, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); }\[/code\]
 
Back
Top