0
내 앱에서 AndroidAnnotations를 사용하고 있으며, 의도에 추가하고 AndroidAnnotations를 사용하는 활동을 시작하려고 할 때 항상 런타임 오류가 발생합니다. AndroidAnnotations 사용을 중지하면 모든 것이 정상적으로 작동합니다. 여기AndroidAnnotations에서 런타임 오류가 발생했습니다.
public class TimeAndDateShower extends Activity {
//some code
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.time_and_date_shower);
//some code
setButtonListener();
}
public void setButtonListener()
{
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent(TimeAndDateShower.this, DateChooser_.class);
intent.putExtra("SSID", network);
startActivity(intent);
TimeAndDateShower.this.finish();
}
});
}
}
처럼 DateChooser.java 보이는 방법은 다음과 같습니다 :이 같은 DateChooser 구성 활동을 선언의 AndroidManifest.xml에서
@EActivity(R.layout.date_chooser)
public class DateChooser extends Activity {
public String network;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.date_chooser);
setNetworkName();
//some code
}
public void setNetworkName()
{
TextView textView = (TextView)findViewById(R.id.textView4);
network = this.getIntent().getStringExtra("SSID");//using an extra
textView.setText(network);
}
}
: 여기
내 활동을 시작하는 코드입니다name="com.componentix.imwizard.DateChooser_" android:screenOrientation="landscape"> </activity>
그리고 여기 내 런타임 오류의 로그입니다 :
12-17 11:51:32.267: E/AndroidRuntime(3234): FATAL EXCEPTION: main
12-17 11:51:32.267: E/AndroidRuntime(3234): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.componentix.imwizard/com.componentix.imwizard.DateChooser_}: java.lang.NullPointerException
12-17 11:51:32.267: E/AndroidRuntime(3234): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
12-17 11:51:32.267: E/AndroidRuntime(3234): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-17 11:51:32.267: E/AndroidRuntime(3234): at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-17 11:51:32.267: E/AndroidRuntime(3234): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-17 11:51:32.267: E/AndroidRuntime(3234): at android.os.Handler.dispatchMessage(Handler.java:99)
12-17 11:51:32.267: E/AndroidRuntime(3234): at android.os.Looper.loop(Looper.java:137)
12-17 11:51:32.267: E/AndroidRuntime(3234): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-17 11:51:32.267: E/AndroidRuntime(3234): at java.lang.reflect.Method.invokeNative(Native Method)
12-17 11:51:32.267: E/AndroidRuntime(3234): at java.lang.reflect.Method.invoke(Method.java:511)
12-17 11:51:32.267: E/AndroidRuntime(3234): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-17 11:51:32.267: E/AndroidRuntime(3234): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-17 11:51:32.267: E/AndroidRuntime(3234): at dalvik.system.NativeStart.main(Native Method)
12-17 11:51:32.267: E/AndroidRuntime(3234): Caused by: java.lang.NullPointerException
12-17 11:51:32.267: E/AndroidRuntime(3234): at com.componentix.imwizard.DateChooser.setNetworkName(DateChooser.java:30)
12-17 11:51:32.267: E/AndroidRuntime(3234): at com.componentix.imwizard.DateChooser.onCreate(DateChooser.java:22)
12-17 11:51:32.267: E/AndroidRuntime(3234): at com.componentix.imwizard.DateChooser_.onCreate(DateChooser_.java:24)
12-17 11:51:32.267: E/AndroidRuntime(3234): at android.app.Activity.performCreate(Activity.java:5008)
12-17 11:51:32.267: E/AndroidRuntime(3234): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-17 11:51:32.267: E/AndroidRuntime(3234): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-17 11:51:32.267: E/AndroidRuntime(3234): ... 11 more
의 주석 '된 setContentView (R.layout.date_chooser)해야, 당신은 너무, 로그에 따라 NPE가' – Raghunandan
을 디버거를 작동시키고 (30 행의'setNoteworkName()'에 중단 점 추가) 어떤 객체가 사용 가능한지 확인하십시오. 이 문제를 쉽게 해결할 수 있습니다. (또는 실제로 더 많은 세부 정보를 제공하십시오.) – Veger
@Raghunandan 왜 이것을해야합니까? 콘텐츠 뷰를 이미 @EActivity (R.layout.date_chooser)로 설정했다고 생각합니다. –