TabHost控件使用Intent创建子页面,TabActivity如何获取页面的内容情况是要录入数据多,就分了两个页面点保存的时候,如何把页面的内容都获取到对应于Android的示例代码:
com.example.android.apis.view   Tabs3.java
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        final TabHost tabHost = getTabHost();        //这里用的是new Intent(this, List1.class)
        //我怎么获取到List1、List2 输入的内容???
        tabHost.addTab(tabHost.newTabSpec("tab1")
                .setIndicator("list")
                .setContent(new Intent(this, List1.class)));        tabHost.addTab(tabHost.newTabSpec("tab2")
                .setIndicator("photo list")
                .setContent(new Intent(this, List8.class)));
    }

解决方案 »

  1.   

    import android.app.TabActivity;
    import android.content.Intent;
    import android.content.res.Resources;
    import android.os.Bundle;
    import android.widget.TabHost;public class MainActivity extends TabActivity { @Override
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    //得到TabHost对象,针对TabActivity的操作通常都由这个对象完成
    TabHost tabHost = getTabHost();
    //生成一个Intent对象,该对象指向一个Activity
    Intent remoteIntent = new Intent();
    remoteIntent.setClass(this, Mp3ListActivity.class);
    //生成一个TabSpec对象,这个对象代表了一个页
    TabHost.TabSpec remoteSpec = tabHost.newTabSpec("Remote");
    Resources res = getResources();
    //设置该页的Indicator
    remoteSpec.setIndicator("远程列表", res.getDrawable(R.drawable.yuancheng));
    //设置该页的内容
    remoteSpec.setContent(remoteIntent);
    //将设置好的TabSpec对象添加到TabHost当中
    tabHost.addTab(remoteSpec);

    Intent localIntent = new Intent();
    localIntent.setClass(this, LocalMp3ListActivity.class);
    TabHost.TabSpec localSpec = tabHost.newTabSpec("Local");
    localSpec.setIndicator("本地曲库",res.getDrawable(R.drawable.xiazai));
    localSpec.setContent(localIntent);
    tabHost.addTab(localSpec);
    }}
    这是mars老师教程里面的,建议你看看mars老师第一季教程的最后几集,有这方面的介绍