Autore Topic: Problema con Fragemnt e MapView  (Letto 369 volte)

Offline Lellihna

  • Nuovo arrivato
  • *
  • Post: 1
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    nexus 5
  • Sistema operativo:
    Windows
Problema con Fragemnt e MapView
« il: 30 Giugno 2014, 16:58:38 CEST »
0
Ho problema con le mappe vi allego il codice e il logcat. Non riesco a capire l'errore. Mi date qualche consiglio?

Codice (Java): [Seleziona]
public class LocationChooser extends FragmentActivity {

        public static SQLiteDatabase db = StorybookContentProvider.myOpenHelper
                        .getWritableDatabase();

        static Cursor cursor;

        static StorybookActivity sa;

        MapController mapController;
        LocationManager locationManager;
        LocationListener locationListener;
        //MapView mapView;
        MapController mc;
        GeoPoint p;
       
       
    private static GoogleMap map;
    private static MarkerOptions marker=null;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //getmyMap();
            setContentView(R.layout.map);
           
            sa = (StorybookActivity) this.getParent();
       
                Drawable drawable = this.getResources().getDrawable(R.drawable.logo);
                //MapItemizedOverlay itemizedoverlay = new MapItemizedOverlay(drawable,this);
               
                // get locations from db
                cursor = db.rawQuery("SELECT " + StorybookContentProvider.LATITUDE
                                + "," + StorybookContentProvider.LONGITUDE + ","
                                + StorybookContentProvider.LOCATION + ","
                                + StorybookContentProvider.STREET + " FROM "
                                + StorybookContentProvider.DATABASE_TABLE_CONTACT, null);

                while (cursor.moveToNext()) {
                        float lat = cursor.getFloat(cursor
                                        .getColumnIndex(StorybookContentProvider.LATITUDE));
                        float lon = cursor.getFloat(cursor
                                        .getColumnIndex(StorybookContentProvider.LONGITUDE));
                        String luogo = cursor.getString(cursor
                                        .getColumnIndex(StorybookContentProvider.LOCATION));
                        String street = cursor.getString(cursor
                                        .getColumnIndex(StorybookContentProvider.STREET));
                        GeoPoint point = new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6));
                        // design geopoint
                       
                        // add to map
                        LatLng coordinate= new LatLng(lat, lon);
                       
                         if (marker!=null){
                     marker.position(coordinate);
                     } else {
                             marker = new MarkerOptions().position(coordinate).title(luogo + " , " + street);
                             map.addMarker(marker);
                     }
                     CameraUpdate center=CameraUpdateFactory.newLatLng(coordinate);
                     CameraUpdate zoom=CameraUpdateFactory.zoomTo(15);
                     map.moveCamera(center);
                     map.animateCamera(zoom);

                }


                cursor.close();

                Button bt = (Button) findViewById(R.id.canc_sett);
                // cancel location
                bt.setOnClickListener(new View.OnClickListener() {

                        public void onClick(View v) {
                                // TODO Auto-generated method stub
                                sa.setLocation("");
                                sa.setTabColor(sa.tabHost, false);

                        }
                });
           
    }


questo codice mi lancia questo errore


Codice (Java): [Seleziona]
06-30 16:55:27.753: E/AndroidRuntime(6148): FATAL EXCEPTION: main
06-30 16:55:27.753: E/AndroidRuntime(6148): Process: com.paki.storybook, PID: 6148
06-30 16:55:27.753: E/AndroidRuntime(6148): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
06-30 16:55:27.753: E/AndroidRuntime(6148):     at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.app.Activity.setContentView(Activity.java:1929)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at com.paki.storybook.LocationChooser.onCreate(LocationChooser.java:67)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.app.Activity.performCreate(Activity.java:5231)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2024)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
06-30 16:55:27.753: E/AndroidRuntime(6148):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)