I'm new in Android. I'm trying to set up a simple TabHost view.
This is my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TabHost
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@+id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#160203" />
<FrameLayout
android:id="@+id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
</FrameLayout>
And here is my java code:
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
public class Tabhost extends FragmentActivity {
private FragmentTabHost tabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tabhost);
tabHost = (FragmentTabHost) findViewById(R.id.tabhost);
tabHost.setup(this, getSupportFragmentManager(), R.id.tabcontent);
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Articulos"),
ArticulosFragment.class, null);
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("Tutoriales"),
TutorialesFragment.class, null);
tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("Cursos"),
CursosFragment.class, null);
}
}
But the app crash with this error message (I really don't know that it means):
What do you think could be wrong?
Use instead:
<android.support.v4.app.FragmentTabHost
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
(...)
</android.support.v4.app.FragmentTabHost>