質問編集履歴
1
質問修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
nullpointerexception
|
1
|
+
インスタンス化でnullpointerexception
|
body
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
38行目のTextView mTextView = new TextView(this);でエラーが起きているようです。表示する段階でnullならエラーが出るのがまだ分かるですが、なぜインスタンス化する段階でこのようなエラーが出るのでしょうか。そして解決するにはどのようにしたらいいのでしょうか?
|
2
2
|
|
3
|
-
```
|
3
|
+
```java
|
4
4
|
|
5
5
|
public class MainActivity extends Activity implements Runnable, SensorEventListener {
|
6
6
|
private static final float ACCEL_WEIGHT = 3f;
|
@@ -54,7 +54,7 @@
|
|
54
54
|
|
55
55
|
|
56
56
|
```
|
57
|
-
```
|
57
|
+
```
|
58
58
|
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
|
59
59
|
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
|
60
60
|
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
|