我有三個標籤,我想用它來利用我的三個網頁瀏覽來顯示特定的域。一切都建立發現,但是當我嘗試啓動程序的時候,力當我運行它&如果我調試它關閉 - 它保持與開放的佈局和視圖(在調試的時候它基本上什麼都不做。)如何在選項卡中使用WebView並調用「(LocalActivityManager activityGroup)」?
logcat的說
無法啓動活動ComponentInfo {com.company.client/com.company.client.MainActivity}:java.lang.IllegalStateException:你忘了叫 '公共無效設置(LocalActivityManager的ActivityGroup)' **
我該如何稱呼?
繼承人我的代碼:
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends Activity {
TabHost th;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
th = (TabHost) findViewById(R.id.tabhost);
th.setup();
TabSpec firstSpec=th.newTabSpec("Classes & Events");
firstSpec.setIndicator("Classes & Events", null);
Intent firstIntent= new Intent(this, WebViewActivity.class);
firstIntent.putExtra("backswipe", false);
firstSpec.setContent(firstIntent);
th.addTab(firstSpec);
TabSpec secondSpec=th.newTabSpec("Twitter");
secondSpec.setIndicator("Twitter", null);
Intent secondIntent= new Intent(this, WebViewActivity2.class);
secondSpec.setContent(secondIntent);
th.addTab(secondSpec);
TabSpec thirdSpec=th.newTabSpec("Facebook");
thirdSpec.setIndicator("Facebook", null);
Intent thirdIntent= new Intent(this, WebViewActivity3.class);
thirdSpec.setContent(thirdIntent);
th.addTab(thirdSpec);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
web視圖代碼
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
public class WebViewActivity extends Activity {
public WebView webView_A;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
webView_A = (WebView) findViewById(R.id.tab1);
webView_A.getSettings().setJavaScriptEnabled(true);
webView_A.loadUrl("http://www.eventbrite.com");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.web_view, menu);
return true;
}
}
的XML主要佈局
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFB84D" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-3dip"
android:layout_weight="0" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
</FrameLayout>
</LinearLayout>
</TabHost>
繼承人的logcat的。
1月5日至23日:23:06.886:W/dalvikvm(14673):線程ID = 1:螺紋帶 未捕獲的異常(組= 0x4160e930) 1月5日至23日在退出:23:06.910:E/AndroidRuntime (14673):致命例外:main 05-23 01:23:06.910:E/AndroidRuntime(14673):java.lang.RuntimeException:無法啓動活動 ComponentInfo {com.company.client/com.company.client .MainActivity}: java.lang.IllegalStateException:你忘記調用'public void setup(LocalActivityManager activityGroup)'嗎? E/AndroidRuntime(14673):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307) 05-23 01:23:06.910:E/AndroidRuntime(14673): 05-23 01:23:06.910:在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2357) 05-23 01:23:06.910:E/AndroidRuntime(14673):at android.app.ActivityThread.access $ 600(ActivityThread.java:153) 05 -23 01:23:06.910:E/AndroidRuntime(14673):at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1247) 05-23 01:23:06.910:E/AndroidRuntime(14673):at android.os.Handler.dispatchMessage(Handler.java:99) 05-23 01:23:06.910:E/AndroidRuntime(14673):at android.os.Looper.loop(Looper.java:137) 05-23 01:23:06.910:E/AndroidRuntime(14673):at android.app.ActivityThread.main(A E/AndroidRuntime(14673):at java.lang.reflect.Method.invokeNative(Native Method) 05-23 01:23:06.910:E/AndroidRuntime (14673):at java.lang.reflect.Method.invoke(Method.java:511) 05-23 01:23:06.910:E/AndroidRuntime(14673):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller .run(ZygoteInit.java:795) 05-23 01:23:06.910:E/AndroidRuntime(14673):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562) 05-23 01 :23:06.910:E/AndroidRuntime(14673):在dalvik.system.NativeStart.main(本地方法) 05-23 01:23:06.910:E/AndroidRuntime(14673):引起:java.lang.IllegalStateException:你忘了打電話給'public void setup(LocalActivityManager activityGroup)'嗎? 05-23 01:23:06.910:E/AndroidRuntime(14673):at android.widget.TabHost $ IntentContentStrategy.getContentView(TabHost。java/747) 05-23 01:23:06.910:E/AndroidRuntime(14673):at android.widget.TabHost.setCurrentTab(TabHost.java:413) 05-23 01:23:06.910:E/AndroidRuntime 14673):at android.widget.TabHost.addTab(TabHost.java:240) 05-23 01:23:06.910:E/AndroidRuntime(14673):at com.company.client.MainActivity.onCreate(MainActivity.java: 28) 05-23 01:23:06.910:E/AndroidRuntime(14673):at android.app.Activity.performCreate(Activity.java:5104) 05-23 01:23:06.910:E/AndroidRuntime(14673) :at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 05-23 01:23:06.910:E/AndroidRuntime(14673):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261) 05 -23 01:23:06.910:E/AndroidRuntime(14673):... 11更多
那麼,我怎樣才能得到我的WebViewActivities活性在標籤中,並做什麼logcat告訴我?