1000 questions in android need to create 1000 activities? - android

I'm doing a app that will ask question to users like:
what is the capital of australia?
Camberra - paris - washington - toquio
and I will have 4 options, so user can select the right one.
When it choose the answer the next question will show.
I'd like to know if I need to create one activity for each of this questions/answers or there is another method? can I have examples?

'You can use Viewpager or viewFlipper for that purpose. in this way you can show all of your's questions in one activity'

I would change dynamically the content of the question and answers components.
If you animate the changes in those components it will look really nice and you'll be saving resources that you would waste creating an activity for each question.

Related

Android Design: Activity only or Fragments?

I am working on an app for school children. Basically, there would be questions with multiple choice answers as in image below. Main requirements are:
Each round of a test will have 10 questions (configurable)
Questions with answers are loaded from an api
The test is timed. So each question will be visible for 10 seconds and then the next one will be presented, maybe with some animation/slide effect
My question is which of the below is the better way to do the above?
Have the questions and answers appear in a UI fragment while storing data in a model fragment. New questions are provided by wiring up an adaptor.. something like a ViewPager without swipes
Everything is one Activity. Change the question and answers by changing android:text using maybe a handler and postDelayed()
Is option 1 better as it might handle Config changes better? Or is it easier to just use option 2. Thanks..
If you don't intend to have fancy UI, go for Option 2. And architect your code using MVP approach, where the logic is in the Presenter, and the View portion handle by the Activity.
You could read more on MVP in http://antonioleiva.com/mvp-android/

Android Questonnaire layout approach

I want to create a questionnaire but I'm not sure what is the best way to approach this. I'm pretty new to Android but at the moment I have a working app which has a main activity screen which has various options. One of them is to launch the questionnaire. I have created a single database table which contains 4 columns Question Number, Question, Answer, Explanation. The explanation is displayed when the user selects the incorrect answer.
I am envisaging that the screen will be simple enough, just a textview containing the question and 3 buttons, 'YES' 'NO' 'BACK'. I plan to have 15 questions. What I'm wondering is do I have to create an activity for every question and every explanation even though the layout is going to be the same from one question to the next?
Definitely not!
Do this the way you would in any other application. Put your questions in some kind of list and iterate through them. Set the content "question" view, in your layout with the successive values.
... and remember to save the position in the list across Pause and Resume!
Ultimately to get this to work I had to use a counter which I incremented after each successive question. No list was required.

Explain the different navigation types, Android

I've been setting up an app for awhile now and now that I know exactly what I'm doing, I'm ready to pretty much restart and make a new version that's more user-friendly. While creating the app, Eclipse want to know what navigation type I want.
None
Tabs
Tabs+Swipe
Swipe View+Title Strip
Dropdown
Can somebody either explain (or give a link to something that explains) what the bottom four options look like and how to use them? So far all I've used is the 'none' option and I simply used buttons and a menu to navigate. I'd like to learn about the other options to make my app as sleek as possible.
--This part was answered: http://android-er.blogspot.com/2012/06/various-navigation-type-provided-in-new.html
But the 2nd part of this question:
Is is possible to have one navigation at one point in time and another type of navigation at a different time?
Example: Start-splash screen, go to login screen. Once logged in, go to a menu. If they pick 'edit forms', it brings them to a Swipe Views + Title Strip setup where each different view is a different form.
Is this what you want? It was the first search result. http://android-er.blogspot.com/2012/06/various-navigation-type-provided-in-new.html
Is that what you are looking for?
Android Developers
As the first part of your question has been answered and i cannot yet comment, i will consider this an "answer" to your second question:
It is not typically considered appropriate to post multi-part questions on Stack Overflow. Why you may ask? For situations exactly like this one. You have half your question answered and accepted that answer as the correct one, However... What of the second question? What if someone decides to answer it and gives a good answer. Only one person may have their answer marked as correct. And considering that those ratings change the level of interaction you may have on Stack Overflow, It would be wrong to accept one half and not the other simply because they were given by 2 different people.
If you have a question that is in some way a subset of your first, leave a comment on the answer in which you need elaboration. ie: (Question 1 = "What is a class?"; Question 2 = "Why would i need such a functionality?";)
If you have a question that is a fork in your first thought, create a new question. ie: (Question 1 = "What is a class?"; Question 2 = "What does it mean to instantiate an object?";)
If the core subject matter is different, you should create a new question. Otherwise you leave a comment. But never put 2 questions in 1 unless they would have the same problem / solution.
anyways...best wishes, on a year old post =P

Android 30 Activity, how to make them into one

Lets say, I want to make a quiz application. And I have 90 question - 3 question on each activity which is 30 activity. The way I know how to make all those Activities is to make a class for each of them. 30 class is a lot.
I'm using this method:
startActivity(new Intent(this, Myclass.class));
What is the best way to make all those activities? Or can it all happen in one?
Thanks, comment if something is not explained clearly.
I would try to separate the data (the questions/answers) from the view (the activities) and use some Intent.putExtra() to open one quiz activity with a parameter to let it know which questions to load/show.
I am not sure, but I think that to share the questions data between the activity instances you could put them in a static variable in that activity.
If the plan is to go like start quiz -> good answer -> start another quiz -> ... then you might want to use android:noHistory to avoid leaving all old question activities in memory.
One thing that you could do is use a viewflipper within a single activity, to show a few different views there. Perhaps you could group your questions and use a single activity for each group, using the viewflipper for each group...
bigstones is correct. You need to separate the data from the Activity, and only create a single Activity. Then, you could have a button that they click when they've answered the set of questions they're currently viewing. Clicking that button would show a progress spinner, and then load the next 3 questions in the background. This should all be done with a single Activity.
Mauzam.
I have a better solution .
You could also use one activity ,and use an Expandable List view instead.
this activity will have all the question in it and when someone clicks on a particular question, this list view would expand to show the options and when answer is selected, u can store it somewhere.
here is an example:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ExpandableList1.html
I hope this helps!!

android: how to create multiply views screen?

I want to create an activity, which shows a question with 4 answers, and at the bottom of the screen i want to place a timer.
I have already found timer example, and i created a question with the answers. the problem that they are 2 different projects and activities, and i am looking for the best way to implement it. i think i can't show 2 activities on one screen, but i can show 2 views or shell i use the ViewGroup, or maybe to copy-paste one of the activities code to another ( its the easiest way but probably the most ugliest way to implement it).
please tell me what is the best way, that i will study and not to waste time to study all the ways and only then to choose one of them.
welcome to StackOverflow.
You are correct in that you cannot display two activities at once. You must instead look into how layouts work in Android by reading some tutorials on the Android developer guide.
For your layout, I would recommend using a LinearLayout with four TextView objects inside it containing the questions (and perhaps your EditText objects below them) as well as your timer. Make sure they are all inside a ScrollView so the software keyboard doesn't force it all to be squeezed up. This is how I would approach it, but I encourage you to read about how layouts work and use the XML resources.
The Notepad tutorial is an excellent way to get started with views and text entry, as well as using SQLite databases.

Categories

Resources