0

单击按钮时,我想打开另一个活动。我看不出问题出在哪里。我希望这里有人能告诉我出了什么问题。

onClick 活动一:

    public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
    case R.id.bBerakna:

        if (isEditTextEmpty(anslag_mm) | isEditTextEmpty(bladVikten)
                | isEditTextEmpty(jamnViktsLage)
                | isEditTextEmpty(rotorSpann) | isEditTextEmpty(varv_Minut)) {

            Toast t = Toast.makeText(this,
                    "Du måste fylla i alla parametrarna!",
                    Toast.LENGTH_SHORT);
            t.show();
            break;
        } else {
            Intent resultat = new Intent(Input.this,
                    ExpandableListViewAppActivity.class);
            resultat.putExtra("ROTOR", rotorSp);
            resultat.putExtra("RPM", rpm);
            resultat.putExtra("JVIKT", jämVikL);
            resultat.putExtra("BVIKT", bladVikt);
            resultat.putExtra("ANSLAG", anslFäLä);              
            startActivity(resultat);
        }
    };

这是应该打开的活动二的 onCreate:

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

        Intent getIntent = getIntent();
        rotorSp = (double) getIntent.getDoubleExtra("ROTOR", 0);
        rpm = (double) getIntent.getDoubleExtra("RPM", 0);
        jämVikL = (double) getIntent.getDoubleExtra("JVIKT", 0);
        bladVikt = (double) getIntent.getDoubleExtra("BVIKT", 0);
        anslFäLä = (double) getIntent.getDoubleExtra("ANSLAG", 0);

    berakna();

    // Döljer tangentbordet
    InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(
            getCurrentFocus().getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);

    setContentView(R.layout.main);

}

这是来自 LogCat:

    01-20 19:09:09.068: E/AndroidRuntime(722): FATAL EXCEPTION: main
    01-20 19:09:09.068: E/AndroidRuntime(722): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rotorbladen.tobias/com.rotorbladen.tobias.ExpandableListViewAppActivity}: java.lang.NullPointerException
    01-20 19:09:09.068: E/AndroidRuntime(722):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    01-20 19:09:09.068: E/AndroidRuntime(722):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    01-20 19:09:09.068: E/AndroidRuntime(722):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    01-20 19:09:09.068: E/AndroidRuntime(722):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    01-20 19:09:09.068: E/AndroidRuntime(722):  at android.os.Handler.dispatchMessage(Handler.java:99)
    01-20 19:09:09.068: E/AndroidRuntime(722):  at android.os.Looper.loop(Looper.java:123)
    01-20 19:09:09.068: E/AndroidRuntime(722):  at android.app.ActivityThread.main(ActivityThread.java:4627)
    01-20 19:09:09.068: E/AndroidRuntime(722):  at java.lang.reflect.Method.invokeNative(Native Method)
    01-20 19:09:09.068: E/AndroidRuntime(722):  at java.lang.reflect.Method.invoke(Method.java:521)
   01-20 19:09:09.068: E/AndroidRuntime(722):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
   01-20 19:09:09.068: E/AndroidRuntime(722):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
   01-20 19:09:09.068: E/AndroidRuntime(722):   at dalvik.system.NativeStart.main(Native Method)
   01-20 19:09:09.068: E/AndroidRuntime(722): Caused by: java.lang.NullPointerException
   01-20 19:09:09.068: E/AndroidRuntime(722):   at com.rotorbladen.tobias.ExpandableListViewAppActivity.onCreate(ExpandableListViewAppActivity.java:92)
   01-20 19:09:09.068: E/AndroidRuntime(722):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
   01-20 19:09:09.068: E/AndroidRuntime(722):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
   01-20 19:09:09.068: E/AndroidRuntime(722):   ... 11 more
4

0 回答 0