0
我得到了这个类,onCreate内没有任何东西发生?初始化时不会自动调用吗?Android:没有任何过去正在发生
代码在下面,非常感谢! - Micheal
package com.michealbach.livedrops;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import android.app.Activity;
public class AnyClass extends Activity {
double latitude = 0;
double longitude = 0;
String addressString = "Address Initialized";
String postalString = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
postalString = "Why doesn't this String change happen at all?";
}
public double getLongitude() {
return longitude;
}
public double getLatitude() {
return latitude;
}
public String getAddress() {
return addressString;
}
public String getPostal() {
return postalString;
}
}
这样做会导致“应用程序意外停止,请重试”。如果我将字符串初始化为一组字符而不是null,它将保持这种状态。它不应该在onCreate()内部做什么并做出改变?
谢谢Falmarri,但它并不适用于我的问题。我正在做的“//做的东西”是updateWithNewLocation(Location location)方法。 我的问题具体指的是在onCreate中什么也没有发生。第一行是对字符串postalString的更改 - 但是在打印出postalString时不会反映出来。我也假定下面的事情都没有发生。 – Micheal 2010-08-23 22:27:45
我的回答回答你的问题。没有任何事情发生,因为你的onLocationChanged方法是GetLocation的方法,而不是LocationListener。在你的代码中,为什么你认为onCreate()之后会发生什么?你认为什么是调用你的其他方法? – Falmarri 2010-08-23 23:00:16
只需用'updateWithNewLocation(位置)'替换'//做东西'' – Falmarri 2010-08-23 23:08:46