Here is all the error message:
java.lang.RuntimeException: Unable to start activity ComponentInfo{johnny.newopen/johnny.newopen.easy}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(int)' on a null object reference
at johnny.newopen.easy.onCreate(easy.java:126)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Here is the relevant code:
public class easy extends AppCompatActivity
{
Button solve;
private Chronometer chronometer;
TextView plus1, plus2, minus1, minus2, multy1, multy2, points;
int p1, p2, m1, m2, mu1, mu2, p, p_ans, m_ans, mu_ans;
long time;
private DBHelper mydb;
boolean check, check1, check2, check3, check4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_easy);
mydb = new DBHelper(this);
if (check1 && check2 && check3) {
p = p + 60 - (int) time;
}
mydb.insertPoints(p);
points = (TextView)findViewById(R.id.points);
int x;
try {
{x = mydb.getPoints();}
}
catch (Exception e) {x=0;}
points.setText(x);
}
}
I keep getting a null pointer for points. What am I doing wrong?