Use the static method View.inflate(Context, int, ViewGroup): http://developer.android.com/reference/android/view/View.html#inflate(android.content.Context,%20int,%20android.view.ViewGroup)
You should be able to use null for the third parameter in this case. --Mark On Mar 9, 7:19 am, Lucius Fox <lucius.fo...@gmail.com> wrote: > Hi, > > In the Tab2 of TabActivity in the APIDemo example, it has this method > to create a View object for each tab: > public View createTabContent(String tag) { > final TextView tv = new TextView(this); > tv.setText("Content for tab with tag " + tag); > return tv; > } > > Can you please tell me how can I create a View for each tab from an > xml layout file? > For example: > public View createTabContent(String tag) { > // load the content from 'tab_content.xml' file > // return a View object > > } > > // tab content.xml looks something like: > <LinearLayout > android:orientation="vertical" > android:layout_width="fill_parent" > android:layout_height="wrap_content"> > > <Button android:id="@+id/button" > android:text="@string/controls_1_save" > android:layout_width="wrap_content" > android:layout_height="wrap_content"/> > </LinearLayout> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---