2017-05-05 39 views
-4

編程新手我知道我正在做的事情可能顯然是錯誤的做傳遞或使用錯誤的變量,但我不能解決什麼。無法解析符號myLatitude

這裏是我的代碼:

public class CameraViewActivity extends Activity implements 
    SurfaceHolder.Callback, OnLocationChangedListener, OnAzimuthChangedListener { 


private double mAzimuthReal = 0; 
private double mAzimuthTheoretical = 0; 
private static double AZIMUTH_ACCURACY = 5; 
private double mMyLatitude = 0; 
private double mMyLongitude = 0; 




private List<Double> calculateAzimuthAccuracy(double azimuth) { 
    double minAngle = azimuth - AZIMUTH_ACCURACY; 
    double maxAngle = azimuth + AZIMUTH_ACCURACY; 
    List<Double> minMax = new ArrayList<Double>(); 


@Override 
public void onAzimuthChanged(float azimuthChangedFrom, float azimuthChangedTo) { 
    mAzimuthReal = azimuthChangedTo; 
    mAzimuthTheoretical = calculateTheoreticalAzimuth(); 

    pointerIcon = (ImageView) findViewById(R.id.icon); 


    double minAngle = calculateAzimuthAccuracy(mAzimuthTheoretical).get(0); 
    double maxAngle = calculateAzimuthAccuracy(mAzimuthTheoretical).get(1); 




    if (isBetween(minAngle, maxAngle, mAzimuthReaal) { 

     pointerIcon.setVisibility(View.VISIBLE); 

    } 
    else { 
     pointerIcon.setVisibility(View.INVISIBLE); 

    } 

    updateDescription(); 
} 

感謝您閱讀

+1

歡迎來到Stack Overflow!請[請重新參觀](http://stackoverflow.com/tour)以查看網站的工作原理和問題,並相應地編輯您的問題。另請參閱:[如何創建最小,完整和可驗證的示例](http://stackoverflow.com/help/mcve) –

+0

您的字段未在'onAzimuthChanged'中引用...也請不要大寫變量,請 –

+0

他們未解決哪些行?你幾乎在任何地方都在使用它們。 –

回答

0

使用

isRange(mMyLatitude, mMyLongitude, mPoi.getPoiLatitude(), mPoi.getPoiLongitude) 

,而不是使用小寫字母來命名變量。

+0

謝謝!我肯定會修復:D – Screenager

+0

快樂編碼:) – FAT

0

在此功能,您需要通過爲paramters或者兩個位置,並用自己的座標功能INRANGE或傳遞四個座標和使用他們。

public void onAzimuthChanged(float azimuthChangedFrom, float azimuthChangedTo) { 
mAzimuthReal = azimuthChangedTo; 
mAzimuthTheoretical = calculateTheoreticalAzimuth(); 

pointerIcon = (ImageView) findViewById(R.id.icon); 


double minAngle = calculateAzimuthAccuracy(mAzimuthTheoretical).get(0); 
double maxAngle = calculateAzimuthAccuracy(mAzimuthTheoretical).get(1); 




if (isBetween(minAngle, maxAngle, mAzimuthReal) && isRange(MyLatitude, MyLongitude, MpoiLatitude, MpoiLongitude)) { 

    pointerIcon.setVisibility(View.VISIBLE); 

} 
else { 
    pointerIcon.setVisibility(View.INVISIBLE); 

} 

updateDescription(); 
} 

這沒有任何意義

isRange(MyLatitude, MyLongitude, MpoiLatitude, MpoiLongitude); 

一兩件事,適應專業的命名標準。給出以大寫字母開頭的屬性名稱相當於MEH。的

isRange(MyLatitude, MyLongitude, MpoiLatitude, MpoiLongitude) 

僅供參考,其更好

+0

謝謝你的建議,我嘗試過,但他們仍然沒有解決:( – Screenager

+0

看到我更新的答案 –