I tried to use setContent() to get an activity in TabHost, but it
failed. The detail codes are followed:
import android.app.Activity;
import android.os.Bundle;
import android.widget.TabHost;
import android.content.Intent;
public class Test extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabs=(TabHost)findViewById(R.id.tabhost);
tabs.setup();
TabHost.TabSpec spec=tabs.newTabSpec("tag1");
spec.setContent(R.id.tab1);
spec.setIndicator("$ Dollar ");
tabs.addTab(spec);
spec.setContent(R.id.tab2);
spec.setIndicator("£ Pound");
spec.setContent(new Intent(this, List1.class));
tabs.addTab(spec);
tabs.setCurrentTab(0);
}
}
List1.java is followed:
import android.app.Activity;
import android.os.Bundle;
public class List1 extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.cal);
}
}
cal.xml :
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:text="hello_world" />
Thank you very much for your help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---