I found a lot of examples to create tabs using an xml file in android, but I need to create multiple tabs programmatically. Please guide me.
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:tag="tab0"
android:text="Tab 1"
android:background="@android:drawable/btn_star_big_on"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
<TextView
android:tag="tab1"
android:text="Tab 2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
<TextView
android:tag="tab2"
android:text="Tab 3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
</TabWidget>
How can I write this programmatically instead of the above xml code.
Check Tab With Swipe example. It has implementation of tabs without xml files.
But there is XML layout for each fragment. You can drop it as per your requirement.