[Logo]
Forums Register Login
Calculating Score For Quiz App
I do make a quiz app for Android. I parse JSON datas and have them written to radio group with radiobuttons. I could not exactly calculate the score. I tried to write a isRightAnswer method but even so, when i call the method the app crashes. trueResult is my score variable. The matter is mostly about the last part of the don't waste time with parsing part upside.

I wonder if this expression is wrong?



Or this?



Here is my QuizActiviyAdjectives class.



If someone can write me the snippet or tips for the solution would be awesome. Thanks in advance.
The problem is at this part.

if(((RadioButton) grp_options.getChildAt(grp_options.getCheckedRadioButtonId())).getText().equals(rightAnswers.get(i)))


Here is the log.

05-05 16:10:42.380: E/AndroidRuntime(16461): FATAL EXCEPTION: main
05-05 16:10:42.380: E/AndroidRuntime(16461): Process: org.example.ydsquizapp, PID: 16461
05-05 16:10:42.380: E/AndroidRuntime(16461): java.lang.NullPointerException
05-05 16:10:42.380: E/AndroidRuntime(16461): at org.example.ydsquizapp.QuizActivityAdjectives$1.onClick(QuizActivityAdjectives.java:124)
05-05 16:10:42.380: E/AndroidRuntime(16461): at android.view.View.performClick(View.java:4461)
05-05 16:10:42.380: E/AndroidRuntime(16461): at android.view.View$PerformClick.run(View.java:18523)
05-05 16:10:42.380: E/AndroidRuntime(16461): at android.os.Handler.handleCallback(Handler.java:733)
05-05 16:10:42.380: E/AndroidRuntime(16461): at android.os.Handler.dispatchMessage(Handler.java:95)
05-05 16:10:42.380: E/AndroidRuntime(16461): at android.os.Looper.loop(Looper.java:136)
05-05 16:10:42.380: E/AndroidRuntime(16461): at android.app.ActivityThread.main(ActivityThread.java:5118)
05-05 16:10:42.380: E/AndroidRuntime(16461): at java.lang.reflect.Method.invokeNative(Native Method)
05-05 16:10:42.380: E/AndroidRuntime(16461): at java.lang.reflect.Method.invoke(Method.java:515)
05-05 16:10:42.380: E/AndroidRuntime(16461): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
05-05 16:10:42.380: E/AndroidRuntime(16461): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
05-05 16:10:42.380: E/AndroidRuntime(16461): at dalvik.system.NativeStart.main(Native Method)


How can i fix it ? Another way to write it?
One more edit...

The problem at this part of the block below.



Is there another way to write it? Sorry for flooding.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Dec 15, 2017 14:58:32.