TABS TOタブが表示されます。コードは以下の通りです:AndroidのMAPは
import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.widget.TabHost; import android.widget.TabHost.OnTabChangeListener; import android.widget.TabHost.TabContentFactory;
import com.google.android.maps.MapActivity; import com.google.android.maps.MapView;
パブリッククラスタブMapActivityがOnTabChangeListener {
private static final String HOME_TAG = "Home";
private static final String PLAYERS_TAG = "Players";
private static final String MAP_TAG = "Map";
private static final String TICKET_TAG = "Ticket";
private TabHost tabHost;
private MapView mapView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tabHost = (TabHost)findViewById(android.R.id.tabhost);
tabHost.setup();
tabHost.setOnTabChangedListener(this);
mapView = (MapView)findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.postInvalidate();
tabHost.addTab(tabHost.newTabSpec(HOME_TAG).setIndicator("Home").setContent(new Intent(this, Home.class)));
tabHost.addTab(tabHost.newTabSpec(PLAYERS_TAG).setIndicator("Players").setContent(new Intent(this, Players.class)));
tabHost.addTab(tabHost.newTabSpec(MAP_TAG).setIndicator("Venue").setContent(new TabContentFactory() {
public View createTabContent(String arg0) {
return mapView;
}
}));
for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
{
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#00CC33"));
}
tabHost.getTabWidget().setCurrentTab(0);
tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#3399FF"));
}
public void onTabChanged(String tabId) {
for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
{
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#00CC33"));
}
tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#3399FF"));
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
私のマニフェストを実装延び:
<application android:icon="@drawable/englandrugbyrose"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen">
<activity android:name=".Splash"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Tabs" />
<activity android:name=".Home" />
<activity android:name=".Players" />
<activity android:name=".Tickets" />
<activity android:name=".Map" />
<uses-library android:name="com.google.android.maps" />
</application>
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
Btw、私のXMLは、コンテンツを読み込むためのmapview idを含むmap.xmlなどの異なるXMLファイルにあります。これは、私と他の人のXMLとの唯一の違いです。
UPDATE:logcat
それはmapView.setBuiltInZoomControls(真)で35行目を指します。 nullpointer例外を使用すると
ありがとうございます。
エラーコードの出力は、貼り付けたコードよりも役に立ちます。クラッシュの原因となった行番号を与える必要があります。 – schwiz
私はlogcatに精通していませんか?それは何ですか? – user701071
私はlogcatをオープンしていますが、コード35のようにnullpointer例外が発生しています。ダブルクリックすると、mapView.setBuiltInZoom(true)が強調表示されます。 – user701071