不解析符号

时间:2017-04-15 14:28:40

标签: java android symbols private-class

我想知道是否有人能告诉我为什么在下面的代码中,mLat和mLon给我的错误说这个符号无法解决?

我很确定我已经在私人课程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;
                }
            });

我有点难过。

由于

编辑:显示我定义mFavPlaceCoords的位置。另外,我将mFavPlaceCoords作为私有对象:

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();

            }

0 个答案:

没有答案