Java 使用片段在actionbar中设置tabhost

Java 使用片段在actionbar中设置tabhost,java,android,Java,Android,我用过actionbar,效果很好。我在actionbar中有四个片段。我想在其中一个片段中实现tabhost。我使用了以下代码 package com.main.udebate; import android.support.v4.app.Fragment; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Gravity;

我用过actionbar,效果很好。我在actionbar中有四个片段。我想在其中一个片段中实现tabhost。我使用了以下代码

    package com.main.udebate;

import android.support.v4.app.Fragment;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

public class Info extends Fragment {
    public Info() {
    }

    public static final String ARG_SECTION_NUMBER = "section_number";
    private TabHost mTabHost;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        Intent i = new Intent(Info.this, about.class);

         View view = inflater.inflate(R.layout.info, container, false);
         mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
         mTabHost.setup();

        TabHost.TabSpec tab = mTabHost.newTabSpec("my tab content");
        tab.setIndicator("my tab content");
        tab.setContent(i);
        mTabHost.addTab(tab);
        mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
        return view;

    }
}
我在
Intent I=newintent(Info.this,about.class)上出错行,因为构造函数意图(信息、类)未定义

关于.java

  package com.main.udebate;

import android.app.Activity;
import android.os.Bundle;

public class about extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
    }
}
有人能帮我在碎片内设置tabhost吗

谢谢,

试着用这个

Intent i = new Intent(getActivity(), about.class); 
而不是这条线

Intent i = new Intent(Info.this, about.class);
这并不意味着任何上下文,这就是为什么您会得到“构造函数意图(信息,类)未定义”这个错误

在使用
this
reference的片段中,应改为使用
getActivity()
reference

检查此-->