相关疑难解决方法(0)

在Android中添加片段内的片段?

我想在片段中添加一个TabHost.代码如下.这里面是碎片.我正在尝试添加TabHost以显示两个选项卡:

package com.nordicsoft.dilosysNewVersion;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;

public class Fragment_Coupons extends Fragment {
    TabHost tabHost;
    TabHost.TabSpec spec;

    public Fragment_Coupons() {
    }

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

        View rootView = inflater.inflate(R.layout.fragment_coupon, container,
                false);
        tabHost = (TabHost) rootView.findViewById(android.R.id.tabhost);
        tabHost.setup();
        //Add_Text_To_Tab("Android", "IOS");

        Intent intentAndroid = new Intent().setClass(getActivity(),
                Aclass.class);
        spec = tabHost.newTabSpec("Android").setContent(intentAndroid)
                .setIndicator("Android");

        tabHost.addTab(spec);

        Intent intentBus = new Intent().setClass(getActivity(), Bclass.class);
        spec = tabHost.newTabSpec("Welcome").setIndicator("Welcome")
                .setContent(intentBus).setIndicator("Welcome");
        tabHost.addTab(spec);
        return rootView;
    }

} …
Run Code Online (Sandbox Code Playgroud)

android fragment android-tabs

36
推荐指数
2
解决办法
5万
查看次数

标签 统计

android ×1

android-tabs ×1

fragment ×1