0

I was wondering if anyone could tell me why in the code below, mLat and mLon are giving me errors saying that the symbol cannot be resolved?

I'm pretty sure I have defined them correctly in the private class GPSCoords:

private class GPSCoords {
    float mLat, mLon;

    GPSCoords(float lat, float lon) {
        mLat = lat;
        mLon = lon;

    }
}

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
        case PLACE_DIALOG_ID:

            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final View dialogLayout = layoutInflater.inflate(R.layout.fav_place_dialog, (ViewGroup) findViewById(R.id.root));

            final TextView placeCoordinates = (TextView) dialogLayout.findViewById(R.id.TextView_FavPlaceCoords_Info);
            final EditText placeName = (EditText) dialogLayout.findViewById(R.id.EditText_FavPlaceName);
            placeName.setOnKeyListener(new View.OnKeyListener() {

                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {

                        String strPlaceName = placeName.getText().toString();
                        if ((strPlaceName != null) && (strPlaceName.length() > 0)) {
                            // Try to resolve string into GPS coords
                            resolveLocation(strPlaceName);

                            Editor editor = mGameSettings.edit();
                            editor.putString(GAME_PREFERENCES_FAV_PLACE_NAME, placeName.getText().toString());
                            editor.putFloat(GAME_PREFERENCES_FAV_PLACE_LONG, mFavPlaceCoords.mLon);
                            editor.putFloat(GAME_PREFERENCES_FAV_PLACE_LAT, mFavPlaceCoords.mLat);
                            editor.commit();

                            placeCoordinates.setText(formatCoordinates(mFavPlaceCoords.mLat, mFavPlaceCoords.mLon));
                            return true;
                        }
                    }
                    return false;
                }
            });

I'm a bit stumped.

Thanks

EDIT: Showing where I've defined mFavPlaceCoords. Also, I have mFavPlaceCoords as a private Object:

if (mGameSettings.contains(GAME_PREFERENCES_FAV_PLACE_NAME)) {

                // Retrieve favorite place from preferences
                strFavPlaceName = mGameSettings.getString(GAME_PREFERENCES_FAV_PLACE_NAME, "");
                mFavPlaceCoords = new GPSCoords(mGameSettings.getFloat(GAME_PREFERENCES_FAV_PLACE_LAT, 0), mGameSettings.getFloat(GAME_PREFERENCES_FAV_PLACE_LONG, 0));

            } else {

                // No favorite place set, set coords to current location
                strFavPlaceName = getResources().getString(R.string.settings_favplace_currentlocation); // We do not name this place ("here"), but use it as a map point. User can supply the name if
                // they like
                calculateCurrentCoordinates();

            }
Phil Adams
  • 95
  • 2
  • 16

0 Answers0