package com.example.t;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.app.TabActivity;
import android.view.LayoutInflater;
import android.widget.TabHost;
public class TActivity extends TabActivity {
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_t);
TabHost mTabHost = (TabHost) findViewById (R.id.tabhost);
mTabHost.setup ();
LayoutInflater inflater_tab1 = LayoutInflater.from (this);
inflater_tab1.inflate (R.layout.a, mTabHost.getTabContentView ());
inflater_tab1.inflate (R.layout.b, mTabHost.getTabContentView ());
mTabHost.addTab (mTabHost.newTabSpec ("tab_test1") setIndicator ("TAB a") setContent (R.id.LinearLayout01)..);
mTabHost.addTab (mTabHost.newTabSpec ("tab_test2") setIndicator ("TAB b") setContent (R.id.FrameLayout02)..);
}
}
XML part
xmlns: android = "http://schemas.android.com/apk/res/android"
android: id = "@ + id / tabhost"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent">android: orientation = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent">android: id = "@ android: id / tabs"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content" />android: id = "@ android: id / tabcontent"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent">
This part of what is the problem? I do not see where there are problems uh, seeking advice
Here is the error content

I feel the question should be out in this one

New to java, many do not really understand
Reply:
Since inherited TabActivity, then
android: id = "@ + id / tabhost"
Here's id should be android: id = "@ android: id / tabhost"
Then call getTabHost () in the activity of the object can be obtained tahbost
Reply:
Thanks! ! Phrase

No comments:
Post a Comment