![]() ![]() ![]() ![]() |
|||||
|
|||||
樓主 愛睏的黑黑 ![]()
![]() |
不知道為甚麼~我的首頁出現不是我想要的頁面 (如下圖) ![]() 所以想請大大幫我看一下程式碼是不是出了什麼問題 main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <com.google.android.maps.MapView android:id="@+id/map" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="0N9YrrpYaxARqDiE5NNXj44yP2wZ4O1ADarQAXw" android:clickable="true" /> <Button android:id="@+id/h1" android:text="租借站" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginLeft="5dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="7dip" /> <Button android:id="@+id/m1" android:text="捷運資訊" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="65dip" android:layout_marginLeft="5dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="7dip" /> <Button android:id="@+id/s1" android:text="景點推薦" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="125dip" android:layout_marginLeft="5dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="7dip" /> <Button android:id="@+id/go1" android:text="規劃路徑" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="185dip" android:layout_marginLeft="5dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="7dip" /> <Button android:id="@+id/photo" android:text="河濱自行車導覽圖" android:layout_width= "wrap_content" android:layout_height="wrap_content" android:layout_marginTop="365dip" android:layout_marginLeft="5dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="7dip" /> <Button android:id="@+id/my" android:text="定位" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginLeft="260dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="10dip" /> <Button android:id="@+id/Satellite" android:text="衛星" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="65dip" android:layout_marginLeft="260dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="10dip" /> <Button android:id="@+id/Traffic" android:text="交通" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="125dip" android:layout_marginLeft="260dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="10dip" /> <Button android:id="@+id/End" android:text="關閉" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="365dip" android:layout_marginLeft="260dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="10dip" /> <LinearLayout android:id="@+id/zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /> </RelativeLayout> green.xml <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <com.google.android.maps.MapView android:id="@+id/myMapView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="0N9YrrpYaxARqDiE5NNXj44yP2wZ4O1ADarQAXw" android:clickable="true" /> - <!-- 建立第一個Button --> <Button android:id="@+id/btn" android:text="關渡租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginLeft="0dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn1" android:text="大稻埕租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginLeft="85dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn2" android:text="大佳租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginLeft="170dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn3" android:text="美堤租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginLeft="255dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn4" android:text="景福租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="60dip" android:layout_marginLeft="0dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn5" android:text="木柵租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="60dip" android:layout_marginLeft="85dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn6" android:text="觀山租借站(假日服務)" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="60dip" android:layout_marginLeft="170dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn7" android:text="華中租借站(假日服務)" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="60dip" android:layout_marginLeft="255dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn8" android:text="雙溪租借站(假日服務)" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="115dip" android:layout_marginLeft="0dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn9" android:text="彩虹租借站(假日服務)" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="115dip" android:layout_marginLeft="85dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn10" android:text="八里租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="115dip" android:layout_marginLeft="170dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn11" android:text="華江埕租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="115dip" android:layout_marginLeft="255dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn12" android:text="二重租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="170dip" android:layout_marginLeft="0dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn13" android:text="浮洲租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="170dip" android:layout_marginLeft="85dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn14" android:text="碧潭租借站" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="170dip" android:layout_marginLeft="170dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn15" android:text="龍形租借站(假日服務)" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="170dip" android:layout_marginLeft="255dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn16" android:text="微風租借站(假日服務)" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="225dip" android:layout_marginLeft="0dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn17" android:text="永和租借站(假日服務)" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="225dip" android:layout_marginLeft="85dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn18" android:text="柑園租借站(假日服務)" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="225dip" android:layout_marginLeft="170dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btn19" android:text="汐止租借站(假日服務)" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="225dip" android:layout_marginLeft="255dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btna" android:text="淡水河河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="280dip" android:layout_marginLeft="0dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btnb" android:text="基隆河河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="280dip" android:layout_marginLeft="85dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btnc" android:text="貴子坑溪河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="280dip" android:layout_marginLeft="170dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btnd" android:text="雙溪河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="280dip" android:layout_marginLeft="255dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btne" android:text="新店溪河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="335dip" android:layout_marginLeft="0dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btnf" android:text="景美溪河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="335dip" android:layout_marginLeft="85dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btng" android:text="淡水河河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="335dip" android:layout_marginLeft="170dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btnh" android:text="基隆河河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="335dip" android:layout_marginLeft="255dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btni" android:text="貴子坑溪河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="390dip" android:layout_marginLeft="0dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btnj" android:text="雙溪河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="390dip" android:layout_marginLeft="80dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btnk" android:text="新店溪河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="390dip" android:layout_marginLeft="170dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btnl" android:text="景美溪河濱自行車道" android:layout_width="85dip" android:layout_height="wrap_content" android:layout_marginTop="390dip" android:layout_marginLeft="255dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btnr" android:text="首頁" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="435dip" android:layout_marginLeft="65dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <Button android:id="@+id/btnend" android:text="關閉" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="435dip" android:layout_marginLeft="135dip" android:layout_marginRight="5dip" android:layout_marginBottom="10dip" android:padding="5dip" /> <LinearLayout android:id="@+id/zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /> </RelativeLayout> </ScrollView> star.java package com.demo.android.miniblack; import java.util.ArrayList; import java.util.List; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.Toast; import com.google.android.maps.GeoPoint; import com.google.android.maps.ItemizedOverlay; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.MyLocationOverlay; import com.google.android.maps.Overlay; import com.google.android.maps.OverlayItem; public class star extends MapActivity { /** Called when the activity is first created. */ private Button my; private Button Satellite; private Button Traffic; private Button End; private Button s1; private Button h1; private Button m1; private Button photo; private Button go1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); my = (Button)findViewById(R.id.my); Satellite = (Button)findViewById(R.id.Satellite); Traffic = (Button)findViewById(R.id.Traffic); End = (Button)findViewById(R.id.End); h1 = (Button)findViewById(R.id.h1); s1 = (Button)findViewById(R.id.s1); m1 = (Button)findViewById(R.id.m1); photo = (Button)findViewById(R.id.photo); go1 = (Button)findViewById(R.id.go1); findViews(); setupMap(); go1.setOnClickListener(new Button.OnClickListener() { public void onClick(View m) { Intent intent = new Intent(); intent.setClass(star.this,miniblack.class); startActivity(intent); star.this.finish(); } }); photo.setOnClickListener(new Button.OnClickListener() { public void onClick(View m) { Uri uri = Uri.parse("http://taoyuan0013.myweb.hinet.net/bike/"); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); } }); h1.setOnClickListener(new Button.OnClickListener() { public void onClick(View m) { Intent intent = new Intent(); intent.setClass(star.this,mini.class); startActivity(intent); star.this.finish(); } }); s1.setOnClickListener(new Button.OnClickListener() { public void onClick(View m) { Intent intent = new Intent(); intent.setClass(star.this,tree.class); startActivity(intent); star.this.finish(); } }); m1.setOnClickListener(new Button.OnClickListener() { public void onClick(View m) { Intent intent = new Intent(); intent.setClass(star.this,wind.class); startActivity(intent); star.this.finish(); } }); my.setOnClickListener(new View.OnClickListener() { public void onClick(View m) { mylayer.enableMyLocation(); mc.animateTo(mylayer.getMyLocation()); List<Overlay> overlays = map.getOverlays(); overlays.add(mylayer); } }); Satellite.setOnClickListener(new View.OnClickListener() { @SuppressWarnings("deprecation") public void onClick(View i) { map.setSatellite(true); map.setTraffic(false); map.setStreetView(true); } }); Traffic.setOnClickListener(new View.OnClickListener() { @SuppressWarnings("deprecation") public void onClick(View j) { map.setSatellite(false); map.setTraffic(true); map.setStreetView(true); } }); End.setOnClickListener(new View.OnClickListener() { public void onClick(View k) { System.exit(0); } }); } @Override protected boolean isRouteDisplayed() { return false; } /*宣告 map 這個 MapView的實體物件, 再用 map 的 getController方法, 取得 mc 這個MapController的實體物件。 ↓↓↓↓↓↓*/ private MapView map; private MapController mc; private ViewGroup zoom; @SuppressWarnings("deprecation") private void findViews(){ map = (MapView) findViewById(R.id.map); mc = map.getController(); zoom = (ViewGroup) findViewById(R.id.zoom); zoom.addView(map.getZoomControls()); } private MyLocationOverlay mylayer; /*在setupMap這段,主要做了設定預設的地圖檢視模式為交通街道圖, 並且預設了地圖起始的縮放尺度,數值越大地圖的細節就越詳細。*/ private void setupMap(){ //這個註解部分是開啟這程式的地圖預設中心點。↓↓↓↓↓↓ /*GeoPoint Taipeistation = new GeoPoint( (int) (25.047192 * 1E6), (int) (121.516981 * 1000000) );*/ map.setTraffic(true); mc.setZoom(17); List<Overlay> overlays = map.getOverlays(); Drawable pin=getResources().getDrawable(R.drawable.bike); pin.setBounds(-pin.getMinimumWidth(), -pin.getMinimumHeight(), 0, 0); mylayer = new MyLocationOverlay(this, map); mylayer.runOnFirstFix( new Runnable() { public void run() { mc.animateTo(mylayer.getMyLocation()); }} ); LandMarkOverlay marklayer = new LandMarkOverlay(pin); overlays.add(marklayer); } @Override protected void onResume() { super.onResume(); mylayer.enableMyLocation(); Toast.makeText(star.this, " - 自行車導覽 - ", Toast.LENGTH_LONG).show(); } @Override protected void onPause() { super.onPause(); mylayer.disableMyLocation(); } @Override protected void onStop() { mylayer.disableMyLocation(); super.onStop(); } // 宣告地點按鈕在MENU上。 ↓↓↓↓↓↓↓↓↓ protected static final int MENU_b1 = Menu.FIRST; protected static final int MENU_b2 = Menu.FIRST+1; protected static final int MENU_b3 = Menu.FIRST+2; protected static final int MENU_b4 = Menu.FIRST+3; protected static final int MENU_b5 = Menu.FIRST+4; protected static final int MENU_b6 = Menu.FIRST+5; protected static final int MENU_b7 = Menu.FIRST+6; protected static final int MENU_b8 = Menu.FIRST+7; protected static final int MENU_b9 = Menu.FIRST+8; protected static final int MENU_b10 = Menu.FIRST+9; protected static final int MENU_b11 = Menu.FIRST+10; protected static final int MENU_b12 = Menu.FIRST+11; protected static final int MENU_exit = Menu.FIRST+0; //建立MENU選單上的按鈕。 ↓↓↓↓↓↓↓↓↓ @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, MENU_b1, 0, "淡水河河濱自行車道"); menu.add(0, MENU_b2, 0, "基隆河河濱自行車道"); menu.add(0, MENU_b3, 0, "貴子坑溪河濱自行車道"); menu.add(0, MENU_b4, 0, "雙溪河濱自行車道"); menu.add(0, MENU_b5, 0, "新店溪河濱自行車道"); menu.add(0, MENU_b6, 0, "景美溪河濱自行車道"); menu.add(0, MENU_b7, 0, "淡水河河濱自行車道"); menu.add(0, MENU_b8, 0, "基隆河河濱自行車道"); menu.add(0, MENU_b9, 0, "貴子坑溪河濱自行車道"); menu.add(0, MENU_b10, 0, "雙溪河濱自行車道"); menu.add(0, MENU_b11, 0, "新店溪河濱自行車道"); menu.add(0, MENU_b12, 0, "景美溪河濱自行車道"); menu.add(0, MENU_exit, 0, "離開"); return true; } //設定地點位置的經緯度。 ↓↓↓↓↓↓↓↓↓ GeoPoint b1 = new GeoPoint( (int) (25.121255 * 1000000), (int) (121.462139 * 1000000) ); GeoPoint b2 = new GeoPoint( (int) (25.137108 * 1000000), (int) (121.490463 * 1000000) ); GeoPoint b3 = new GeoPoint( (int) (25.117130 * 1000000), (int) (121.464716 * 1000000) ); GeoPoint b4 = new GeoPoint( (int) (25.097463 * 1000000), (int) (121.511434* 1000000) ); GeoPoint b5 = new GeoPoint( (int) (25.035441 * 1000000), (int) (121.486800 * 1000000) ); GeoPoint b6 = new GeoPoint( (int) (24.998354 * 1000000), (int) (121.535159 * 1000000) ); GeoPoint b7 = new GeoPoint( (int) (25.036091 * 1000000), (int) (121.487106 * 1000000) ); GeoPoint b8 = new GeoPoint( (int) (25.115164 * 1000000), (int) (121.485357* 1000000) ); GeoPoint b9 = new GeoPoint( (int) (25.062350 * 1000000), (int) (121.612031 * 1000000) ); GeoPoint b10 = new GeoPoint( (int) (25.100440 * 1000000), (int) (121.537081* 1000000) ); GeoPoint b11 = new GeoPoint( (int) (24.998486 * 1000000), (int) (121.535170* 1000000) ); GeoPoint b12= new GeoPoint( (int) (24.999108* 1000000), (int) (121.577081* 1000000) ); //點選MENU上的地點,自動移動到該目標位置。 ↓↓↓↓↓↓↓↓↓ public boolean onOptionsItemSelected(MenuItem item){ super.onOptionsItemSelected(item); switch(item.getItemId()){ case MENU_b1: mc.animateTo(b1); break; case MENU_b2: mc.animateTo(b2); break; case MENU_b3: mc.animateTo(b3); break; case MENU_b4: mc.animateTo(b4); break; case MENU_b5: mc.animateTo(b5); break; case MENU_b6: mc.animateTo(b6); break; case MENU_b7: mc.animateTo(b7); break; case MENU_b8: mc.animateTo(b8); break; case MENU_b9: mc.animateTo(b9); break; case MENU_b10: mc.animateTo(b10); break; case MENU_b11: mc.animateTo(b11); break; case MENU_b12: mc.animateTo(b12); break; } return true; } public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_I) { // 地圖拉近 ↓↓↓↓↓↓↓↓↓ mc.setZoom(Math.min(map.getMaxZoomLevel(), map.getZoomLevel() + 1)); return true; } else if (keyCode == KeyEvent.KEYCODE_O) { // 地圖拉遠 ↓↓↓↓↓↓↓↓↓ mc.setZoom(Math.max(15, map.getZoomLevel() - 1)); return true; } else if (keyCode == KeyEvent.KEYCODE_S) { // 按下 S 鍵地圖顯示衛星空照地圖 ↓↓↓↓↓↓↓↓↓ map.setSatellite(true) ; map.setTraffic(false); return true; } else if (keyCode == KeyEvent.KEYCODE_T) { // 按下 T 鍵地圖顯示交通街道地圖 ↓↓↓↓↓↓↓↓↓ map.setSatellite(false) ; map.setTraffic(true); return true; } else if (keyCode == KeyEvent.KEYCODE_Q) { // 按下 Q 鍵離開程式↓↓↓↓↓↓↓↓↓ System.exit(0); return true; } return false; } //選擇按鈕後在指定的位置上標示星號。 ↓↓↓↓↓↓↓↓↓ public class LandMarkOverlay extends ItemizedOverlay<OverlayItem> { private List<OverlayItem> items = new ArrayList<OverlayItem>(); private List<OverlayItem> items0 = new ArrayList<OverlayItem>(); public LandMarkOverlay(Drawable defaultMarker) { super(defaultMarker); items.add(new OverlayItem( b1, "淡水河河濱自行車道", "基隆河匯入淡水河之前,繞著社子島轉出一個美麗的弧彎,在其北岸與磺港溪以西地帶,保留了都會臺北極其珍貴的稻香田園,連結起河口紅樹林自然保護區,讓人得以在很短的距離內隔絕塵囂嘈雜,單車踩踏其間,尤其能夠體會早年農村氛圍的樸素簡單、踏實自在。")); items.add(new OverlayItem( b2, "基隆河河濱自行車道", "從左岸的林安泰疏散門進入河濱腳踏車道,遊客可以看見紀錄著基隆河緣起,整治故事的解說牌,讓民眾在運動休閒之餘,還能瞭解基隆河長長的歷史典故。 ")); items.add(new OverlayItem( b3, "貴子坑溪河濱自行車道", "穿越關渡平原的自行車道,是全線非封閉性的路徑,西側端點為關渡宮,往東沿著關渡防潮堤至八仙福德祠,轉90度往北穿越關渡平原,直到北投中央北路捷運軌道南側,穿出去便是政戰學校西邊的稻香路。")); items.add(new OverlayItem( b4, "雙溪河濱自行車道", "景色優美的雙溪河畔,引領平日生活繁忙的都市人,找到一條解放疲憊身心的綠色隧道,由雙溪左岸在銜接百齡橋右岸自行車道,百齡橋右岸河濱公園是玩橄欖球愛好者聚集之處。")); items.add(new OverlayItem( b5, "新店溪河濱自行車道", "騎乘此車道,建議可以多預留一些時間在水色宜人、遠離塵囂的碧潭風景特定區繞繞,吊橋、天鵝船、美食街、小噴泉、四季植栽造景,再加上規劃良好的自行車動線,都能讓民眾獲得度假休閒的愉快感受。")); items.add(new OverlayItem( b6, "景美溪河濱自行車道", "有青山綠水相伴的景美溪左、右岸自行車道,沿線有動物園,Zoo Mall、政大球場及青草綠茵,溪流常有魚群穿梭,適合攜家帶眷全家出遊的路線。沿線的景觀相當豐富,翠綠草地,清澈溪流讓人感覺非常舒適。")); items.add(new OverlayItem( b7, "淡水河河濱自行車道", "基隆河匯入淡水河之前,繞著社子島轉出一個美麗的弧彎,在其北岸與磺港溪以西地帶,保留了都會臺北極其珍貴的稻香田園,連結起河口紅樹林自然保護區,讓人得以在很短的距離內隔絕塵囂嘈雜,單車踩踏其間,尤其能夠體會早年農村氛圍的樸素簡單、踏實自在。")); items.add(new OverlayItem( b8, "基隆河河濱自行車道", "從左岸的林安泰疏散門進入河濱腳踏車道,遊客可以看見紀錄著基隆河緣起,整治故事的解說牌,讓民眾在運動休閒之餘,還能瞭解基隆河長長的歷史典故。 ")); items.add(new OverlayItem( b9, "貴子坑溪河濱自行車道", "穿越關渡平原的自行車道,是全線非封閉性的路徑,西側端點為關渡宮,往東沿著關渡防潮堤至八仙福德祠,轉90度往北穿越關渡平原,直到北投中央北路捷運軌道南側,穿出去便是政戰學校西邊的稻香路。")); items.add(new OverlayItem( b10, "雙溪河濱自行車道", "景色優美的雙溪河畔,引領平日生活繁忙的都市人,找到一條解放疲憊身心的綠色隧道,由雙溪左岸在銜接百齡橋右岸自行車道,百齡橋右岸河濱公園是玩橄欖球愛好者聚集之處。")); items.add(new OverlayItem( b11, "新店溪河濱自行車道", "騎乘此車道,建議可以多預留一些時間在水色宜人、遠離塵囂的碧潭風景特定區繞繞,吊橋、天鵝船、美食街、小噴泉、四季植栽造景,再加上規劃良好的自行車動線,都能讓民眾獲得度假休閒的愉快感受。")); items.add(new OverlayItem( b12, "景美溪河濱自行車道", "有青山綠水相伴的景美溪左、右岸自行車道,沿線有動物園,Zoo Mall、政大球場及青草綠茵,溪流常有魚群穿梭,適合攜家帶眷全家出遊的路線。沿線的景觀相當豐富,翠綠草地,清澈溪流讓人感覺非常舒適。")); items0.add(new OverlayItem( b1, "長度:共11.9公里", "。")); items0.add(new OverlayItem( b2, "騎乘時間:左岸約90分鐘,右岸約80分鐘,大直橋、麥帥一橋、彩虹橋、成功橋可銜接兩岸。", "。")); items0.add(new OverlayItem( b3, "長度:貴子坑溪自行車道約5公里。", "。")); items0.add(new OverlayItem( b4, "長度:左右岸各約2.8公里。", "。")); items0.add(new OverlayItem( b5, "騎乘時間:新店溪右岸約30分鐘。新店溪左岸約大漢溪右岸約120分鐘。大漢溪左岸約65分鐘。", "。")); items0.add(new OverlayItem( b6, "騎乘時間:左岸約25分鐘,右岸約40分鐘,可由道南橋、一壽橋連接兩岸。", "。")); items0.add(new OverlayItem( b7, "長度:共11.9公里", "。")); items0.add(new OverlayItem( b8, "騎乘時間:左岸約90分鐘,右岸約80分鐘,大直橋、麥帥一橋、彩虹橋、成功橋可銜接兩岸。", "。")); items0.add(new OverlayItem( b9, "長度:貴子坑溪自行車道約5公里。", "。")); items0.add(new OverlayItem( b10, "長度:左右岸各約2.8公里。", "。")); items0.add(new OverlayItem( b11, "騎乘時間:新店溪右岸約30分鐘。新店溪左岸約大漢溪右岸約120分鐘。大漢溪左岸約65分鐘。", "。")); items0.add(new OverlayItem( b12, "騎乘時間:左岸約25分鐘,右岸約40分鐘,可由道南橋、一壽橋連接兩岸。", "。")); populate(); } /*根據傳入的i值指定了編號,再從items列表中, 抓取對應的物件回傳,並且標試圖標實體。*/ @Override protected OverlayItem createItem(int i) { return items.get(i); } @Override public int size() { return items.size(); } //按下星號後,標示目標資訊。 ↓↓↓↓↓↓↓↓↓ @Override protected boolean onTap(final int pIndex) { new AlertDialog.Builder(star.this) .setTitle(items.get(pIndex).getTitle()+" - 自行車道介紹") .setMessage(items.get(pIndex).getSnippet()) .setIcon(R.drawable.bike) .setNeutralButton("自行車道騎乘時間",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { new AlertDialog.Builder(star.this) .setTitle(items.get(pIndex).getTitle()+" - 自行車騎乘時間") .setMessage(items0.get(pIndex).getTitle()) .setIcon(R.drawable.bike) .setNegativeButton("關閉", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialoginterface, int i){ } }) .show(); } }) .setNegativeButton("關閉", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialoginterface, int i){ } }) .show(); return true; } } } 懇請大大的幫忙 以上是我的程式碼~如果寫得不好請見諒 想執行的首頁如下圖 ![]()
本篇文章發表於2011-07-20 12:09
|
1樓
作者回應
愛睏的黑黑 ![]() |
樓上的大大~如果你很厲害的話~那請你幫我看看吧~因為我找不出原因
況且我最近也才剛學~ 如果你不會~那請你離開這篇我發的文吧
本篇文章回覆於2011-07-21 10:55
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔-- |
2樓 |
:::把AndroidManifest.xml內容PO出來!!!
在AndroidManifest.xml裡的啟始畫面你是設定成star這個畫面嗎???
本篇文章回覆於2011-07-22 09:28
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔-- |
3樓
作者回應
愛睏的黑黑 ![]() |
這是我的AndroidManifest.xml
請版大幫我過目一下~謝謝^^ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.demo.android.miniblack" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <uses-library android:name="com.google.android.maps" /> <activity android:name=".miniblack" 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="mini" /> <activity android:name="tree" /> <activity android:name="wind" /> <activity android:name="miniblack" /> </application> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-sdk android:minSdkVersion="8" /> </manifest>
本篇文章回覆於2011-07-23 20:57
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔-- |
4樓
最有價值解答
小琳 ![]() ![]() |
:::將
<activity android:name=".miniblack" android:label="@string/app_name"> 換成 <activity android:name=".star" android:label="@string/app_name"> 試試!!!
本篇文章回覆於2011-07-24 07:52
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔-- |
5樓
作者回應
愛睏的黑黑 ![]() |
謝謝版大~我已經弄出來了^^
在一次感謝您^^
本篇文章回覆於2011-07-24 15:27
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔-- |
回覆 |
如要回應,請先登入. |