2011-10-25 16 views
0

タブで行ったGoogleマップアプリケーションを開こうとしていますが、動作していないため、実行時に強制終了メッセージが表示され続けます。私はそれだけでテキストを持つクラスを作成する場合、それはと正常に動作アンドロイドのタブにGoogleマップを開く

public class TabstestingActivity extends TabActivity { 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    Resources res = getResources(); 
    TabHost tabHost = getTabHost(); // The activity TabHost 
    TabHost.TabSpec spec; // Reusable TabSpec for each tab 
    Intent intent; // Reusable Intent for each tab 

     intent = new Intent().setClass(this, HelloGoogleActivity.class); 

    spec = tabHost.newTabSpec("tabOne"); 
    spec.setContent(intent); 
    spec.setIndicator("Tab One",res.getDrawable(R.drawable.tabselect)); 
    tabHost.addTab(spec); 
     tabHost.setCurrentTab(0); 
    } 
} 

[HelloGoogleActivityクラスはマップコードが含まれており、それは、タブなしで正常に動作]タブを作成する主な活動ファイル[TabtestingActivity]を作成しました私はマップクラスを追加するとき、それは動作を停止します。 これは私のmain.xmlです:

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/tabhost" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<LinearLayout 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<TabWidget 
android:id="@android:id/tabs" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 
<FrameLayout 
android:id="@android:id/tabcontent  
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<RelativeLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

    <com.google.android.maps.MapView 
    android:id="@+id/mapview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:clickable="true" 
    android:apiKey="my key" 
    android:layout_weight="1"/> 
</RelativeLayout> 
</FrameLayout> 

</LinearLayout> 
</TabHost> 

は私のmain.xmlに問題があるのでしょうか?

これはlogcatです:

10-26 00:47:10.207: ERROR/AndroidRuntime(303): FATAL EXCEPTION: main 
10-26 00:47:10.207: ERROR/AndroidRuntime(303): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tabtest/com.example.tabtest.TabstestingActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class com.google.android.maps.MapView 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.os.Handler.dispatchMessage(Handler.java:99) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.os.Looper.loop(Looper.java:123) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.app.ActivityThread.main(ActivityThread.java:4627) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at java.lang.reflect.Method.invokeNative(Native Method) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at java.lang.reflect.Method.invoke(Method.java:521) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at dalvik.system.NativeStart.main(Native Method) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303): Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.google.android.maps.MapView 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.view.LayoutInflater.createView(LayoutInflater.java:513) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:621) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.app.Activity.setContentView(Activity.java:1647) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at com.example.tabtest.TabstestingActivity.onCreate(TabstestingActivity.java:15) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  ... 11 more 
10-26 00:47:10.207: ERROR/AndroidRuntime(303): Caused by: java.lang.reflect.InvocationTargetException 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at com.google.android.maps.MapView.<init>(MapView.java:238) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at java.lang.reflect.Constructor.constructNative(Native Method) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at java.lang.reflect.Constructor.newInstance(Constructor.java:446) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at android.view.LayoutInflater.createView(LayoutInflater.java:500) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  ... 22 more 
10-26 00:47:10.207: ERROR/AndroidRuntime(303): Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity. 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at com.google.android.maps.MapView.<init>(MapView.java:282) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  at com.google.android.maps.MapView.<init>(MapView.java:255) 
10-26 00:47:10.207: ERROR/AndroidRuntime(303):  ... 26 more 
+0

あなたの質問でlogcatに表示されている例外を投稿してください。 – Craigy

+0

mapviewに余分なレイアウト_重量を持っていることがわかりました – railwayparade

答えて

0

トレースは、あなたがMapActivityの外のMapViewを使用することはできません

"10-26 00:47:10.207: ERROR/AndroidRuntime(303): Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity." 

かなり明確です。

+0

ありがとうございました:) – ukama

関連する問題