这是我在开始 aysncronic 任务时遇到的错误。
01-18 12:21:40.379: E/AndroidRuntime(1102): FATAL EXCEPTION: main
01-18 12:21:40.379: E/AndroidRuntime(1102): java.lang.RuntimeException: Unable to start activity ComponentInfo{ch.edocsyl.spesen/ch.edocsyl.spesen.SpesenActivity}: java.lang.NullPointerException
01-18 12:21:40.379: E/AndroidRuntime(1102): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-18 12:21:40.379: E/AndroidRuntime(1102): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-18 12:21:40.379: E/AndroidRuntime(1102): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-18 12:21:40.379: E/AndroidRuntime(1102): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-18 12:21:40.379: E/AndroidRuntime(1102): at android.os.Handler.dispatchMessage(Handler.java:99)
01-18 12:21:40.379: E/AndroidRuntime(1102): at android.os.Looper.loop(Looper.java:137)
01-18 12:21:40.379: E/AndroidRuntime(1102): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-18 12:21:40.379: E/AndroidRuntime(1102): at java.lang.reflect.Method.invokeNative(Native Method)
01-18 12:21:40.379: E/AndroidRuntime(1102): at java.lang.reflect.Method.invoke(Method.java:511)
01-18 12:21:40.379: E/AndroidRuntime(1102): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-18 12:21:40.379: E/AndroidRuntime(1102): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-18 12:21:40.379: E/AndroidRuntime(1102): at dalvik.system.NativeStart.main(Native Method)
01-18 12:21:40.379: E/AndroidRuntime(1102): Caused by: java.lang.NullPointerException
01-18 12:21:40.379: E/AndroidRuntime(1102): at ch.edocsyl.spesen.SpesenActivity.onCreate(SpesenActivity.java:87)
01-18 12:21:40.379: E/AndroidRuntime(1102): at android.app.Activity.performCreate(Activity.java:5104)
01-18 12:21:40.379: E/AndroidRuntime(1102): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-18 12:21:40.379: E/AndroidRuntime(1102): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-18 12:21:40.379: E/AndroidRuntime(1102): ... 11 more
我的代码:
public class SpesenActivity extends Activity {
ProgressDialog pDialog;
static ApiRestClient arc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_spesen);
final TextView text = (TextView) findViewById(R.id.textView1);
RequestParams params = new RequestParams();
//params.put("username", "james");
pDialog = new ProgressDialog(SpesenActivity.this);
pDialog.setMessage("Loading...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
arc.get("uebersicht.json", params, new JsonHttpResponseHandler() {
public void onSuccess(String response) {
text.setText(response);
pDialog.dismiss();
}
});
你能帮助我吗?