我是爪哇的初学者。这个问题可能有点傻,但请帮帮忙!我已经创建了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(字符序列)不适用于代码的参数(Double):
tvlat.setText(“”+loc.getLatitude());
tvlong.setText(“”+loc.getLongitude());显然,这是因为tvlat和loc是两种不同的类型。有没有人能建议我用正确的方式来表达上面的陈述或解决上面的问题?谢谢你的耐心!
发布于 2013-01-07 00:45:13
引用的格式很奇怪,它与"不同。您可以尝试:
tvlat.setText(String.valueOf (loc.getLatitude()));
tvlong.setText(String.valueOf(loc.getLongitude()));发布于 2013-01-07 00:44:37
使用
tvlat.setText(Double.toString(loc.getLatitude()));
tvlong.setText(Double.toString(loc.getLongitude()));获取双精度值的字符串表示形式
https://stackoverflow.com/questions/14184294
复制相似问题