Possible Duplicate:
Custom Tabwiget for Android
I am very new to Android. I m little confused with the below scenario.
I have created a button and OnClick of that button the user is redirected to an (Android XML layout tab i.e. nurse.xml). Now the redirection is working fine,
nurse.xml contains a tab. The activity is not able to display the tab and thus everything is distorted.
btnSignIn.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
setContentView(R.layout.nurse);
}
}
Sample Code for nurse.xml :
<TabHost
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabHost"
xmlns:android="http://schemas.android.com/apk/res/android">
<TabWidget
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@android:id/tabs" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabcontent">
<!-- Code for READING tab starts here -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/READING"
android:orientation="vertical"
android:paddingTop="60dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="100dp"
android:text="@string/reading_tab" />
</LinearLayout>
<!-- Code for MEDICATION medication starts here -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/MEDICATION"
android:orientation="vertical"
android:paddingTop="60dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="100dp"
android:text="@string/medication_tab" />
</LinearLayout>
</FrameLayout>
</TabHost>
Any help would be helpful,I need nurse.xml to run onClick of the button with tabs.
Thanks !!!
Please write below code instead of your code for add multiple activities in one TabActivity, it will solve your problem.
ActivityStack.java
TabActivity.java
FirstActivity.java
SecondActivity.java
ThirdActivity.java
Add Below XML files into your res/layout folder.
1) tab_screen.xml
2) main.xml
AndroidManifest.xml:-
And see below link for more information on add multiple activities under one TabActivity with complete example.
Android – Multiple Android Activities under one TabActivity