• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Problem with an app , bug

jakobia

Lurker
Nov 26, 2017
7
1
Hi, try to do this app from this youtube video: and I am at 1:27:59


Then I click any button I got this error:

008 12127-12127/se.jakobia.flagsquizapp E/AndroidRuntime: FATAL EXCEPTION: main Process: se.jakobia.flagsquizapp, PID: 12127 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at se.jakobia.flagsquizapp.Playing.onClick(Playing.java:136) at android.view.View.performClick(View.java:5697) at android.widget.TextView.performClick(TextView.java:10826) at android.view.View$PerformClick.run(View.java:22526) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 01-11 12:08:36.228 12127-12127/se.jakobia.flagsquizapp I/Process: Sending signal. PID: 12127 SIG: 9

this line of code is a problem:

txtScore.setText(String.format("%d",score));

There should I start?
 
I tried to export the whole project to a zip file.

I suspect the error is in this lines of codes

"
public void onClick(View v) {

mCountDown.cancel();
if(index < totalQuestion) {
Button clickedButton = (Button)v;
if(clickedButton.getText().equals(questionPlay.get(index).getCorrectAnswer()))
{
score+=10;
correctAnswer++;
showQuestion(++index);
}
else
showQuestion(++index);
txtScore.setText(String.format("%d",score));
}

}
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones