日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Android fragmnet标签,在Android中为Fragment添加标签?

發(fā)布時間:2024/7/19 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android fragmnet标签,在Android中为Fragment添加标签? 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我試圖在Fragment中添加一個TabHost。代碼如下。這里里面的Fragment。我試圖添加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;

}

}

XML代碼:

android:id="@android: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"/>

這給我的錯誤:

12-09 17:40:53.509: E/AndroidRuntime(18103): FATAL EXCEPTION: main

12-09 17:40:53.509: E/AndroidRuntime(18103): java.lang.IllegalStateException: Did you forget to call 'public void setup(LocalActivityManager activityGroup)'?

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:690)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.widget.TabHost.setCurrentTab(TabHost.java:356)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.widget.TabHost.addTab(TabHost.java:246)

12-09 17:40:53.509: E/AndroidRuntime(18103): at com.nordicsoft.dilosysNewVersion.Fragment_Coupons.onCreateView(Fragment_Coupons.java:32)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:828)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1032)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.app.BackStackRecord.run(BackStackRecord.java:622)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1382)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:426)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.os.Handler.handleCallback(Handler.java:605)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.os.Handler.dispatchMessage(Handler.java:92)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.os.Looper.loop(Looper.java:137)

12-09 17:40:53.509: E/AndroidRuntime(18103): at android.app.ActivityThread.main(ActivityThread.java:4517)

12-09 17:40:53.509: E/AndroidRuntime(18103): at java.lang.reflect.Method.invokeNative(Native Method)

12-09 17:40:53.509: E/AndroidRuntime(18103): at java.lang.reflect.Method.invoke(Method.java:511)

12-09 17:40:53.509: E/AndroidRuntime(18103): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)

12-09 17:40:53.509: E/AndroidRuntime(18103): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)

12-09 17:40:53.509: E/AndroidRuntime(18103): at dalvik.system.NativeStart.main(Native Method)

12-09 17:46:02.770: I/Process(18103): Sending signal. PID: 18103 SIG: 9

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的Android fragmnet标签,在Android中为Fragment添加标签?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。