當這個代碼段破例 我不知道exxactly問題出在哪裏..異常改變的EditText字號
Spinner dropdown = (Spinner)findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items);
dropdown.setAdapter(adapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
etFName.setTextSize(TypedValue.COMPLEX_UNIT_SP,Integer.parseInt(items[position]));
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
這裏是我的logcat:
12-07 23:04:35.047: E/AndroidRuntime(7505): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.invitationcard/com.example.invitationcard.Graduation}: java.lang.NullPointerException
12-07 23:04:35.047: E/AndroidRuntime(7505): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
12-07 23:04:35.047: E/AndroidRuntime(7505): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
12-07 23:04:35.047: E/AndroidRuntime(7505): at android.app.ActivityThread.access$600(ActivityThread.java:123)
12-07 23:04:35.047: E/AndroidRuntime(7505): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
12-07 23:04:35.047: E/AndroidRuntime(7505): at android.os.Handler.dispatchMessage(Handler.java:99)
12-07 23:04:35.047: E/AndroidRuntime(7505): at android.os.Looper.loop(Looper.java:137)
12-07 23:04:35.047: E/AndroidRuntime(7505): at android.app.ActivityThread.main(ActivityThread.java:4424)
12-07 23:04:35.047: E/AndroidRuntime(7505): at java.lang.reflect.Method.invokeNative(Native Method)
12-07 23:04:35.047: E/AndroidRuntime(7505): at java.lang.reflect.Method.invoke(Method.java:511)
12-07 23:04:35.047: E/AndroidRuntime(7505): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-07 23:04:35.047: E/AndroidRuntime(7505): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-07 23:04:35.047: E/AndroidRuntime(7505): at dalvik.system.NativeStart.main(Native Method)
12-07 23:04:35.047: E/AndroidRuntime(7505): Caused by: java.lang.NullPointerException
12-07 23:04:35.047: E/AndroidRuntime(7505): at com.example.invitationcard.Graduation.onCreate(Graduation.java:46)
12-07 23:04:35.047: E/AndroidRuntime(7505): at android.app.Activity.performCreate(Activity.java:4492)
12-07 23:04:35.047: E/AndroidRuntime(7505): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-07 23:04:35.047: E/AndroidRuntime(7505): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
12-07 23:04:35.047: E/AndroidRuntime(7505): ... 11 more
有任何人知道什麼是我的錯誤?
請發佈完整活動的代碼 – JacksOnF1re 2014-12-07 22:20:10
Whi ch行引起異常? – Rami 2014-12-07 22:23:38
好吧,我會把它作爲一個答案 – 2014-12-07 22:41:28