私はJavaの初心者です。質問はばかげているかもしれませんが、助けてください!TextViewタイプのtvlatとtvlongをグローバルオブジェクトとして作成しました。
public TextView tvlat;
public TextView tvlong;
次のコードでそれらを使用する場合:
public class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
loc.getLatitude();
loc.getLongitude();
String Text = "Current location : " +
"Lattitude = " + loc.getLatitude() +
"Longitude = " + loc.getLongitude();
Toast.makeText( getApplicationContext(), Text, Toast.LENGTH_SHORT).show();
tvlat.setText(“”+loc.getLatitude());
tvlong.setText(“”+loc.getLongitude());
TextView型のsetText(char sequence)は、コードのarguments(double)には適用できないと書かれています。
tvlat.setText(“”+loc.getLatitude());
tvlong.setText(“”+loc.getLongitude());
明らかに、tvlatとlocは2つの異なるタイプであるために発生します。上記のステートメントをキャストしたり、上記の問題を解決したりする正しい方法を誰かが私に提案できますか?お待ち頂きまして、ありがとうございます!