Suppose your code for adding items to a Ext.carousel.Carousel in Sencha Touch looks like this

To add these same data dynamically, place the code within its initialize function and do your looping there. Check out this sample code.

In Android, we normally use the R class in order to gain access to the drawable, layout, string (and others) variables.

I made this helper method to get a resource id dynamically. However, if you have no need for this, it is a better option to use the R class directly as the search operation is quicker compared to this.

Let us say, you have an XML file named help.xml in your res/layout/ folder. To use the method, do it like this.

Here is a sample code to load XML layout files at runtime within your Android application. Basically, you have to have a Layout tag within your main XML file so that we get to have a placeholder to where we want to store our content.

Then in your code, follow this:

where a is the class that extends Activity. If you are going to place this code within your class that extends Activity, you don’t need to include the a. in the code. Of course, this does not restrict to LinearLayout alone. You can use all other layouts to add new Views as its content.

Related Posts Plugin for WordPress, Blogger...