2011-08-13 128 views
0

我搜索了這樣的其他帖子,但我沒有找到解決方案。 任何人都知道爲什麼,我得到這個消息時,我選擇偏好形成的菜單:窗口已經聚焦

窗口已經集中,忽略了聚焦增益:[email protected]

活動在清單文件中聲明。

import com.cartrafficlive.R; 
import com.google.android.maps.MapActivity; 
import com.google.android.maps.MapController; 
import com.google.android.maps.MapView; 

import android.app.Activity; 
import android.content.Context; 
import android.content.Intent; 
import android.content.SharedPreferences; 
import android.os.Bundle; 
import android.preference.PreferenceManager; 
import android.view.Menu; 
import android.view.MenuItem; 

public class ShowMap extends MapActivity{ 

    static final private int MENU_PREFERENCES = Menu.FIRST; 
    private static final int SHOW_PREFERENCES = 1; 

    MapController mapController; 

    String depAdd; 
    String arrAdd; 

    @Override 
    public void onCreate(Bundle savedInstanceState){ 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.show_map); 

     MapView myMapView = (MapView)findViewById(R.id.myMapView); 
     mapController = myMapView.getController(); 

     myMapView.setSatellite(true); 
     myMapView.setStreetView(true); 
     myMapView.displayZoomControls(true); 

     mapController.setZoom(17); 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu){ 
     super.onCreateOptionsMenu(menu); 

     menu.add(0, MENU_PREFERENCES, Menu.NONE, R.string.menu_preferences); 

     return true; 
    } 

    public boolean onOptionItemSelected(MenuItem item){ 
     super.onOptionsItemSelected(item); 

     switch(item.getItemId()){ 
      case(MENU_PREFERENCES): { 
       Intent i = new Intent(this, Preferences.class); 
       startActivityForResult(i, SHOW_PREFERENCES); 

       return true; 
      } 
     } 
     return false; 
    } 

    @Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 

     if (requestCode == SHOW_PREFERENCES) 
     if (resultCode == Activity.RESULT_OK) { 
      updateFromPreferences(); 
     } 
    } 

    private void updateFromPreferences() { 
     Context context = getApplicationContext(); 
     SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 

     depAdd = prefs.getString(Preferences.PREF_DEP_ADD, "null"); 
     arrAdd = prefs.getString(Preferences.PREF_ARR_ADD, "null"); 
    } 

    @Override 
    protected boolean isRouteDisplayed() { 
     return false; 
    } 

} 

回答

0

我解決這行代碼:

menu.addIntentOptions(Menu.NONE, Menu.NONE, Menu.NONE, this.getComponentName(), null, i, Menu.NONE, null); 
相關問題