Thank you so much, sir! Sir, I m creating the mini project for my college everything was done but I want to show the result in the last page. By watching your video I get my result. Thank You, sir.
Hi Volodymyr Voytenko, thank you for your amazing video, I was wondering if you could show or at least suggest how to go a bout creating a method whereby the questions that have been answered correctly do not come up again until for example all questions have been answered correctly where they all get reset, and get updated as normal.
I do not think it's hard to update the current code for the task you suggested. You work with array list of questions, and its' easy to manage - dynamically delete items, or add.
Hi, Volodymyr Voytenko, I have managed to get this method done with an Arraylist and it works great, however the downside is that if you close the app, the Arraylist data gets cleared. Please can you recommend something that I can replace the Arraylist with so that the data is not lost once the app is closed.
Hi Vlad, I've followed the tutorial you gave, but my program is not running well. When i test it. The buttons does not work. it remains on the first question.
hi Gihon, thanks a lot for your question! Well, if buttons don't work and there is no any other errors, you have to check if the method - a click listener - attached to those buttons. It's easy to fix - just open your layout xml and check it. Hope it will help!
Hi vlad I am just wondering how do you randomise the questions without SQLite database? I see your comments underneath saying you can randomise it but I don't know where to put he code in?
Hi Vlad, so basically you would just need to put this in lesson 16 without using the sqlite database to make the questions random then? import java.util.ArrayList; import java.util.List; public class QuestionBank { // declare list of Question objects List list = new ArrayList(); // method returns number of questions in list public int getLength(){ return list.size(); } // method returns question from list based on list index public String getQuestion(int a) { return list.get(a).getQuestion(); } // method return a single multiple choice item for question based on list index, // based on number of multiple choice item in the list - 1, 2, 3 or 4 // as an argument public String getChoice(int index, int num) { return list.get(index).getChoice(num-1); } // method returns correct answer for the question based on list index public String getCorrectAnswer(int a) { return list.get(a).getAnswer(); }
It looks like you may have a typo error for the variable(s).... Please, check carefully name of the TextView variables in this file, plus names of their widgets.
beause when I delete txtScore.setText("Your Score " + score) i start not with the main activity but the second activity open itself (HighestScoreActivity)
I can't seem to find it. What i want to do is have a set of questions randomly chosen from the array then stops if all of the questions in the array are used.
Hey sir, can you help me please? I have 2 checkbox with yes and with no. Olso I have a button who swich the activities.. I want to know how I can show the rezult from that 2 checkbox on the second activies.
It is not difficult, Adrian! Please, check a video how to switch between Activities: ua-cam.com/video/uMfQv6BaG5A/v-deo.html How to press Button and Switch to the next screen ? Follow simple steps to find out !
Hi master Vlad, I have a problem. When I add 10 questions, in the sixth question my program stops, not update to the next question. I've followed all your tutorials..
Hi Gihon, you problem is not Android-related. Well, if you can reach questions from 1 to 6, but not further, check your code very carefully: you probably have a typo somewhere.
I need your help! I have a problem. When i click on one of the options when there is a question, i don't get to the next question and literally nothing happens (no score update, no next question, nothing). Do you know how i can fix this?
I found what was missing, but still thanks for the fast reply! But now i have another problem, if i finish the quiz and i get the screen with try again. If i press the back button on my phone i get the last question again. If i do this a lot and press the correct answer over and over again, i can get 30 points as high score, but i only have 10 questions... Do you know how i can fix this?
Here you have some more information about the app. I am sorry i am asking so many questions, but the problem is here. You have in your tutorial: Your score: 3 and Highscore: 3. I have 2 times a quiz what referes to the same page with try again on it. If i do the second quiz my "Your score" gets updated for quiz 1 and quiz 2. If i do quiz 1, only my first "Your score" gets updated.
hi, in my quiz activity. the "point" in (int point) and the onClick says "Method is never used" . when i tested it, the buttons does not work, it remains on the first question. what could be the problem? this is the onClick: private void updateScore(int point){ mScoreView.setText("" + mScore+"/"+mQuestionLibrary.getLength()); } public void onClick(View view) { Button answer = (Button) view; if (answer.getText() == mAnswer) { mScore = mScore + 1; Toast.makeText(quizaActivity.this, "Correct!", Toast.LENGTH_SHORT).show(); } else Toast.makeText(quizaActivity.this, "Wrong!", Toast.LENGTH_SHORT).show(); updateScore(mScore); updateQuestion(); } }
I found the error in my code. Now it is working. What should i replace if i want to make an image quiz app? I mean replace the questions with images. Only the question is replaced the multiple choices are the same.
Marj, you can add picture to current layout to have quiz app with images. You have to work more on a layout level. Please, check another video, Lesson 10_1 : ua-cam.com/video/2fFdz108whI/v-deo.html
Hey Vlad Votenko, I am a new fun! Thank you for your tutorials. I have a problem and would be thankful if you help me out with it. I don't want to have an on click listener on each button or on my radio buttons, I want the answers and questions be added and calculated through another button, suppose something like " Next Question " button on each page. I tried alot but couldn't figure out. Would you mind coding it for me ? thanks ind advance,
Thank you, Maisam! Your suggested version not very different. But it will be a bit harder, since you need to check the logic for each question separately.
If you had time please do a video on it or you may send me that snippet of code. What do you prefer, saving the records on shared preferences or on Sqlite database ? or it doesnt matter ?
hi Yusor, randomization is done in Lesson18, I am using simple Java randomization in a program, this is not related to Android programming, but only Java.
Questions randomization can be completed using simple Java techniques, this is not related to Android development. One of the standard way to do this is in Java as follows: Random rn = new Random(); int question = rn.nextInt(10) + 1; This will work for generating a question umber from 1 to 10. Make sure you import Random at the top of your code.
Vlad Voytenko im wondering if its possible to do 4 sets of quiz and 100 questions per set using your tutorial video? Or sql is already needed for that? Thanks!
exelente video amigo , como aria si si deseo salir de juego se guarde el nivel y cuando abro la aplicación empiece a jugar donde le eh dejado-. di si quiero ponerle vidas como hago
Thank you for this video sir, I had modify this instead of Button I change it to Imageviwe so that choices are images in a array. I have trouble in the section where the system checks if the button click is equal to the right answer and if it is correct the score will add to1. below is my code to that section it has no error but it doesnt execute the if only the else part. I hoe you could help me out, thank you d ill wait for your response plssssss... if (answer.equals(mAnswer)){ mScore = mScore + 1; Toast.makeText(QuizActivity.this, "Correct!", Toast.LENGTH_SHORT).show(); }else Toast.makeText(QuizActivity.this, "Wrong!", Toast.LENGTH_SHORT).show(); // show current total score for the user
Thank you so much, sir! Sir, I m creating the mini project for my college everything was done but I want to show the result in the last page. By watching your video I get my result.
Thank You, sir.
This is an excellent video. Thank you for sharing it. I have learnt a great deal.
thanks a lot!
@@VladVoytenko You are welcome! :)
Огромное спасибо за урок и за доступ к коду! То, что мне надо
Best Android Tutorials on youtube!
thanks!
"private void updateScore (int point){" it says that parameter point is never used? can you help me with this? :( pls I barely need it :(
Thanks for the informative video Vlad.
you are welcome, Ashish!
Hi Volodymyr Voytenko, thank you for your amazing video, I was wondering if you could show or at least suggest how to go a bout creating a method whereby the questions that have been answered correctly do not come up again until for example all questions have been answered correctly where they all get reset, and get updated as normal.
I do not think it's hard to update the current code for the task you suggested. You work with array list of questions, and its' easy to manage - dynamically delete items, or add.
I got it, Thanks.
Hi, Volodymyr Voytenko, I have managed to get this method done with an Arraylist and it works great, however the downside is that if you close the app, the Arraylist data gets cleared. Please can you recommend something that I can replace the Arraylist with so that the data is not lost once the app is closed.
Hi Vlad, I've followed the tutorial you gave, but my program is not running well. When i test it. The buttons does not work. it remains on the first question.
hi Gihon, thanks a lot for your question! Well, if buttons don't work and there is no any other errors, you have to check if the method - a click listener - attached to those buttons. It's easy to fix - just open your layout xml and check it. Hope it will help!
Vlad Voytenko It's true. that the onClick method in xml has not been attached with onClick in Quiz Activity Java. Thanks a lot Vlad!
Well done! Good job, Gihon! :-)
can you show me how you did it please
just one example
Hussain Albader Type android:onClick="onClick" on each button in the xml. In order for the onClick method in java to connect to xml
Hi vlad I am just wondering how do you randomise the questions without SQLite database? I see your comments underneath saying you can randomise it but I don't know where to put he code in?
hi David, randomization is done in Lesson18, I am using simple Java randomization in a program, this is not related to Android at all.
Vlad Voytenko so If i take that snippet of randomisation code from lesson 18 and put it in my quiz it should make the questions come up randomly?
pretty much, David! you randomize an array of question in your program - this is it!
Hi Vlad, so basically you would just need to put this in lesson 16 without using the sqlite database to make the questions random then?
import java.util.ArrayList;
import java.util.List;
public class QuestionBank {
// declare list of Question objects
List list = new ArrayList();
// method returns number of questions in list
public int getLength(){
return list.size();
}
// method returns question from list based on list index
public String getQuestion(int a) {
return list.get(a).getQuestion();
}
// method return a single multiple choice item for question based on list index,
// based on number of multiple choice item in the list - 1, 2, 3 or 4
// as an argument
public String getChoice(int index, int num) {
return list.get(index).getChoice(num-1);
}
// method returns correct answer for the question based on list index
public String getCorrectAnswer(int a) {
return list.get(a).getAnswer();
}
You just need to shuffle list:
Collections.shuffle(list);
force close after minute 12:20 error =void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference How to solve it ??
It looks like you may have a typo error for the variable(s).... Please, check carefully name of the TextView variables in this file, plus names of their widgets.
Hello sir! Whch name must I insert after: int *which variable?* = intent.getIntExtra("score",0);
txtScore.setText("Your score"+ *which variable?*);
beause when I delete txtScore.setText("Your Score " + score) i start not with the main activity but the second activity open itself (HighestScoreActivity)
Please help me
Hi vlad, how do you randomize the question and restrict it to stop the game at 10 questions only If you have more than 10 questions?
As far as I remember, we already discussed it in the past.... Please, check old messages!
I can't seem to find it. What i want to do is have a set of questions randomly chosen from the array then stops if all of the questions in the array are used.
Hello! What in the code do I have to change if I want that the score will appear also when a answer is false?
Hey sir, can you help me please? I have 2 checkbox with yes and with no. Olso I have a button who swich the activities.. I want to know how I can show the rezult from that 2 checkbox on the second activies.
It is not difficult, Adrian! Please, check a video how to switch between Activities:
ua-cam.com/video/uMfQv6BaG5A/v-deo.html
How to press Button and Switch to the next screen ?
Follow simple steps to find out !
No no no, sir ... I know to do this... I want to show on the second activity what I check on the first in checkboxs.
that's easy for you!
I think... But I DONT KNOW how to do that ... Can you help me with this?
I am busy 24/7, sorry not having time to provide full support for all of you
Hi master Vlad, I have a problem. When I add 10 questions, in the sixth question my program stops, not update to the next question. I've followed all your tutorials..
Hi Gihon, you problem is not Android-related. Well, if you can reach questions from 1 to 6, but not further, check your code very carefully: you probably have a typo somewhere.
Thanks Vlad. I've found the problem. Now my program is running well
really really helpful
Hi, im wondering how do you do get your buttons to work?
please, check the video again - all buttons work just fine!
Also, if you need to check Button video tutorial, please check the link below:
ua-cam.com/video/WN7930A0D_4/v-deo.html
I need your help! I have a problem. When i click on one of the options when there is a question, i don't get to the next question and literally nothing happens (no score update, no next question, nothing). Do you know how i can fix this?
No clue, it works absolutely perfect on my side. Please, check carefully what is missing.
I found what was missing, but still thanks for the fast reply! But now i have another problem, if i finish the quiz and i get the screen with try again. If i press the back button on my phone i get the last question again. If i do this a lot and press the correct answer over and over again, i can get 30 points as high score, but i only have 10 questions... Do you know how i can fix this?
public class onderwerp1 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.onderwerp1);
TextView txtScore = (TextView) findViewById(R.id.textScore);
TextView txtHighScore = (TextView) findViewById(R.id.txtHighScore);
// receive the score from last activity by Intent
Intent intent = getIntent();
int score = intent.getIntExtra("score", 0);
// display current score
txtScore.setText("Your score: " + score + " / 10");
// use Shared preferences to save the best score
SharedPreferences mypref = getPreferences(MODE_PRIVATE);
int highscore = mypref.getInt("highscore", 0);
if(highscore>= score)
txtHighScore.setText("High score: "+highscore + " / 10");
else {
txtHighScore.setText("New highscore: " + score + " / 10");
SharedPreferences.Editor editor = mypref.edit();
editor.putInt("highscore", score);
editor.commit();
}
TextView txtScore2 = (TextView) findViewById(R.id.textScore2);
TextView txtHighScore2 = (TextView) findViewById(R.id.txtHighScore2);
Intent intent2 = getIntent();
int score2 = intent2.getIntExtra("score2", 0);
txtScore2.setText("Your score: " + score2 + " / 10");
SharedPreferences mypref2 = getPreferences(MODE_PRIVATE);
int highscore2 = mypref2.getInt("highscore2", 0);
if(highscore2>= score2)
txtHighScore2.setText("High score: "+highscore2 + " / 10");
else{
txtHighScore2.setText("New highscore: " + score2 + " / 10");
SharedPreferences.Editor editor = mypref2.edit();
editor.putInt("highscore2", score2);
editor.commit();
}
}
Can you tell me what the mistake is?
Here you have some more information about the app. I am sorry i am asking so many questions, but the problem is here. You have in your tutorial: Your score: 3 and Highscore: 3. I have 2 times a quiz what referes to the same page with try again on it. If i do the second quiz my "Your score" gets updated for quiz 1 and quiz 2. If i do quiz 1, only my first "Your score" gets updated.
NICE TOTURAL ,how about if id like to save the score with players name
Just add player name to database - and ask user to enter at the beginning. It should not be hard task.
hello, my 'getLength' is red. " if (mquestionnumber
I have the same problem
it's syntax error, but you didn't provide it ... Check the message and fit the problem
Sorry, I'm new to this coding and java. But the error message is "Cannot resolve method 'getLength()'
all you need to check definition of the method mquestionlibrary.getLength() in your code, if availbale
I have a question,how can i put images and questions in quiz?
Why not? It's very easy - just check a Lesson how to add image to the Activity.
Wait,i just can add image to Activity,how to add for specify question?
P.S.I already know that
Great! When you change the question every time, you have to load new image.
Then in the quiz bank i have to load the images?
well, you can prepare images for each question in quiz bank. But you have to load the image when you update the question only.
hi sir! From where i can get this cod????
drive.google.com/open?id=0B-AihUewoOXfYUEzdVFOSzB2RE0
i cannot access the link to your project as it requires permission.
you have to try again...
maybe just need upgrade the gradle.. that was my little problem..
yup! Gradle upgrade is required in many cases.
Why is it that the game stop stop when reach the last question sir .?
What do you mean by this? when you reach last question, it should show you final score and eventually stop, isn't it?
yes ..sir
fortunately sir I already solve it..thanks for the updates sir
great! thanks a lot for update!
thanks a lot for your comments! I am glad you solved it!
can you help me for problem. how to make a Random Quiz .?
We discussed this solution already. Please, check discussion board for lesson 16 and lesson 18!
Thank you very much
halo sir.
how to create a image quiz?
thanks sir
hi Andri, we discussed it with Урош below. Please, check his questions and answers and let me know if you need more help!
hi, is it possible to share results to other users/devices?
no, you can't do it for current application - all data are private and visible only to one user at this time
you do know how to do it tho,dont you?
If you need it, you have to write application with Content Provider support to share the same data.
Vlad Voytenko would you please help me through the process?
@Vlad Voytenko is the souce code for free?
absolutely!
thanks....
hello, is it possible to highlight the correct answer if you press the wrong answer?
Hello Azimuth, sure, it is possible: once user answer the question, you may highlight the right answer with a different color.
hope you can show us how if you have time. thanks to this tutorial. this helped me a LOT.
great idea. it would be nice if Mr. Voytenko would teach us how.
looking forward to it sir. pls
Please, come to our classes, guys - everyone welcome!
hi, in my quiz activity. the "point" in (int point) and the onClick says "Method is never used" . when i tested it, the buttons does not work, it remains on the first question. what could be the problem? this is the onClick:
private void updateScore(int point){
mScoreView.setText("" + mScore+"/"+mQuestionLibrary.getLength());
}
public void onClick(View view) {
Button answer = (Button) view;
if (answer.getText() == mAnswer) {
mScore = mScore + 1;
Toast.makeText(quizaActivity.this, "Correct!", Toast.LENGTH_SHORT).show();
} else
Toast.makeText(quizaActivity.this, "Wrong!", Toast.LENGTH_SHORT).show();
updateScore(mScore);
updateQuestion();
}
}
Marj, you may simply have a typo somewhere in your code... How about to download the project, import it into your workspace ans run?
I found the error in my code. Now it is working.
What should i replace if i want to make an image quiz app? I mean replace the questions with images. Only the question is replaced the multiple choices are the same.
Marj, you can add picture to current layout to have quiz app with images. You have to work more on a layout level. Please, check another video, Lesson 10_1 :
ua-cam.com/video/2fFdz108whI/v-deo.html
Hi Marj, i have the same problem as you, when i tested it, the button does not work, it remains on the first question. how you fix it?
How to add another quizz section in to one app?
you have to create multiple quiz Activities in this case, organize them in the list view, and call them from Main Activity.
ok i am stuck, i hope you make tutorial video about that,
Thank you, but I am not sure if we have a lot of people interested.
Hey Vlad Votenko,
I am a new fun!
Thank you for your tutorials. I have a problem and would be thankful if you help me out with it.
I don't want to have an on click listener on each button or on my radio buttons, I want the answers and questions be added and calculated through another button, suppose something like " Next Question " button on each page. I tried alot but couldn't figure out. Would you mind coding it for me ?
thanks ind advance,
Thank you, Maisam! Your suggested version not very different. But it will be a bit harder, since you need to check the logic for each question separately.
If you had time please do a video on it or you may send me that snippet of code.
What do you prefer, saving the records on shared preferences or on Sqlite database ? or it doesnt matter ?
of course, using database is a better choice. You may check video from Lesson18 regarding this.
Can you please give me the code on how can i random the questions please?
hi Yusor, randomization is done in Lesson18, I am using simple Java randomization in a program, this is not related to Android programming, but only Java.
do you have a lesson 15 of tutorial of it sir??
yes, it has lesson 15_1, and lesson 15_2
good pm. what if i want to randomize my question. thank you.
Questions randomization can be completed using simple Java techniques, this is not related to Android development. One of the standard way to do this is in Java as follows:
Random rn = new Random();
int question = rn.nextInt(10) + 1;
This will work for generating a question umber from 1 to 10. Make sure you import Random at the top of your code.
it does not finish the game. it just randomize the questions but it does not finish the game. i have 10 question but its more than 10 when i play it.
Btw you said the link is in the bottom? Were is the link for this video? thank you so much
sure, it will play without restrictions - you may need to stop the quiz when you want
Link for the current version of project is posted under the video.
How many questions can I put in one activity?
any specific reason behind that ?
Vlad Voytenko im wondering if its possible to do 4 sets of quiz and 100 questions per set using your tutorial video? Or sql is already needed for that? Thanks!
this video show how to create 1 (one) set for unlimited number of questions.
exelente video amigo , como aria si si deseo salir de juego se guarde el nivel y cuando abro la aplicación empiece a jugar donde le eh dejado-. di si quiero ponerle vidas como hago
Thank you
Cannot access the link
please, try again
Everythig ok now!! Thanks!!!
OK, good to know ;-) Thanks.
Where Can I find the project code ?
I have subscribed your channel.
Please, check your e-mail. Thanks!
access please
open :)
Hey can u give access to your project ?:)
open ;-)
please share the source code
Thank you for this video sir, I had modify this instead of Button I change it to Imageviwe so that choices are images in a array. I have trouble in the section where the system checks if the button click is equal to the right answer and if it is correct the score will add to1. below is my code to that section it has no error but it doesnt execute the if only the else part. I hoe you could help me out, thank you d ill wait for your response plssssss...
if (answer.equals(mAnswer)){
mScore = mScore + 1;
Toast.makeText(QuizActivity.this, "Correct!", Toast.LENGTH_SHORT).show();
}else
Toast.makeText(QuizActivity.this, "Wrong!", Toast.LENGTH_SHORT).show();
// show current total score for the user
Please give me the source code i have subscribed your channel
Hi Azhar, please click on the link below:
drive.google.com/file/d/0B-AihUewoOXfYUEzdVFOSzB2RE0/view?usp=sharing
I have not any link after subscribe your channel
reply plz
Project code for Lesson 16:
drive.google.com/drive/folders/0B-AihUewoOXfZmNmZ1Z3V1JXM0k
не проще на русском было?)
нет, не проще - я уже привык к английскому ), во-вторых, англоязычная аудитория намного шире