-3

これは、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();
        }
    }); 

手伝って頂けますか?

4

3 に答える 3

1

arc使用する前に初期化する必要があります。

arc = new ApiRestClient();
arc.get("uebersicht.json", params, new JsonHttpResponseHandler() {
    public void onSuccess(String response) {
        text.setText(response);
        pDialog.dismiss();
    }
}); 
于 2013-01-18T13:06:22.463 に答える
1

を初期化していませんarc。まず円弧のオブジェクトを作成してから試してみてください。

arc = new ApiRestClient();

を使用する前に上記のコード行を追加してarcください。

于 2013-01-18T13:07:32.003 に答える
0

Step 1 : read the stacktrace

Step 2 : identify the Exception

Step 3 : identify the class, method, and line that caused the exception

Step 4 : find a fix

Step 5 : if you can't find a fix, ask a question mentionning the result of all 4 previous steps

于 2013-01-18T15:01:08.333 に答える