[Q] Andriod Quiz App - Radio Buttons - Java for Android App Development

Okay, so I've been surfing the web for a few weeks/months now but I can't seem to find any decent tutorial for my query.
With high hopes, can anyone show me how to do it on a single activity with at least 10 questions each?
I'm currently developing an M-Learning application. So aside for all the reading materials and somewhat simulations,
I need to present a quiz that will ask users at least 10 - 15 items per chapter.
I'll be presenting it on a graph as well for the user's profile. (But that's another issue I'd tackle later on)
Currently, all I have now was moving from one activity to another and vice versa.
Can anyone please guide me? I'd modify this if it doesn't clarify anything.
Please take interest. Am still a student though.

iamreverie said:
Okay, so I've been surfing the web for a few weeks/months now but I can't seem to find any decent tutorial for my query.
With high hopes, can anyone show me how to do it on a single activity with at least 10 questions each?
I'm currently developing an M-Learning application. So aside for all the reading materials and somewhat simulations,
I need to present a quiz that will ask users at least 10 - 15 items per chapter.
I'll be presenting it on a graph as well for the user's profile. (But that's another issue I'd tackle later on)
Currently, all I have now was moving from one activity to another and vice versa.
Can anyone please guide me? I'd modify this if it doesn't clarify anything.
Please take interest. Am still a student though.
Click to expand...
Click to collapse
Since you have a quiz app I'd recommend a swipe view with 4 radio buttons and a spinner with the chapter in the action bar or chapter list in the navigation drawer. Use 1 fragment and dynamically change the text for each fragment and inflate the swipe views. That way lesser resources.
Sent from my Moto G using XDA Free mobile app

Hi there once again.
I was able to pull off the Swipe View. However, I wanted to ask if this scenario is possible.
I wanted to build the quiz in a single activity only. Is this possible?
Button A ---> QuizActivity(Set1)
Button B ---> QuizActivity(Set2)
I want the quiz to happen on a single activity only but with different set of questions as triggered by different buttons.
Is this possible? And how will I pull this one.
Thanks.

So you want to have a set of buttons and depending on the button (category of questions) clicked you want to start a quiz of that category?
Simple answer to your question though is yes, u can have a quiz in a single activity if you wish.
Sent from my GT-I9300 using XDA Free mobile app

Related

Force redraw of View

hi guys,
i hope this is the correct section in the forum. I have a question concerning to an application some friends and me are developing currently. We have class which extends View.
Now, in regular intervals, this View object (which is a subcomponent in an Activity using Relative Layout) has to be refreshed. The refresh itself is done by mView.postInvalidate in a background thread (lets say, every 300ms). The problem we noticed is, that the postInvalidate() as well as the invalidate() (which we could use if the UI Thread would call it) do NOT force a refresh (thus, calling onDraw(canvas)) immediately! Unfortunately, the view is only updated every 1-3rd second..
Does anyone of you have an idea, how to force an android view, to refresh immediately?
Thanks,
Felix
possibly anddev.org might be a better place?
youre right i think, i posted it also there, thanks!
http://www.anddev.org/view-layout-resource-problems-f27/immediately-view-redraw-problem-t15425.html
you are placing this inside a specific _device_ development forum. It are mostly ROM builders (and users) you are going to find here.
Place questions about app-developing in the genera Android dev forums here on XDA, that's where all the app builders / hackers are

[Q] Each view a new activity?

I'm learning how to program in android and want to make a musicplayer. The problem I have now is I have no idea how to build the views for the application. For example if you start the application you have the options, all songs, artists, albums. If you then select artists you get all the albums from that artist, if you select an album you get the songs etc..
Now my problem. Do I have to make a different activity per view (all songs view, artist view, album view), because they all do almost the same, just fill a listview with some data.
Can sombody point me to a tutorial of give me a hint how to do this because I'm trying to find a solution for 2 weeks now and all 101 "noob" basic tutorial I found don't cover this.
Thanks in advance.
Nobody who can point me to the right direction?
I would create a new activity for each, but create a base class that has the listview in it. Then in each new activity, just inherit from that base class and call a method to fill in that list view with the data specific to that particular activity.
-frank
Sent from my PC36100 using XDA App
Hello!
I'm only new to android development too but I'd suggest two things. Firstly you need to make sure the music playing is being done by a service so it works in the background. Secondly, I don't think you'll need a different activity for each view. List views are populated by adapters if I remember right so maybe one view to choose the music filter and the next view will choose the correct adapter and populate the list....
Hope this helps a little.
Sent from my X10i using XDA App
@kaediil, I think I try that, I'm open for other suggestion tho.
@Keithod, the mechanics to play a song are already done, the vies are the only problem. And I tried it with adapters but how am I'm going to handle the onclick then? That would be one hell of a switch statement.
Is there a tutorial that handles these kind of problems?
If your music player created a database of the metadata, artist, album etc. Then your adapter could use the ID of the element that was clicked as the criteria for the select statement... No switch required and only one activity...
Sent from my X10i using XDA App
I now get the id3 tag from the song and build the views that way, I could dump it in a database when the application start. Let me try that.
After a couple of days I am still stuck, I prefer a tutorial or a snippet how I could fill 1 listview and when I click a specific item another listview or the same will be filled with other items.
Hope somebody can help me with this.
What went wrong with the database idea?
Sent from my X10i using XDA App
Then I still have to display it, or it's from an arraylist or database.
Try using a ViewFlipper: http://developer.android.com/intl/zh-CN/reference/android/widget/ViewFlipper.html
You don't need to have one Activity for every view, you can choose to display different info depending on the previous Screen or if the user has clicked a different button.
An example:
- An user clicks on a button that goes to PSN and recover a list of latest games played by the user with his playstation.
- You put a flag on the Bundle Extras to indicate to the next ListView activity that you want a PSN info.
- In the ListView Activity you recover info from PSN. If the user clicks on the Xbox Live button you use the same Activity to query Microsoft's website. You can even load a different XML Layout for PSN or Xbox Live in that same Activity and have 2 completely different Layouts for a single Activity:
Code:
if (xbox)
setContentView(R.layout.achievements_xbl);
else
setContentView(R.layout.trophies_psn);
Anyway, if the methods are not shared to display different info in the Activities is a good practice to have different Activities Classes, you can have one XML Layout if the List Rows are similar and use in two different Activities.
Helper Classes, to separate business code from Activities are also a great tool.

Store Item Finder / Item Locator

I'm trying to build an app for a school project that will locate items in a grocery store. For example, if I type in "orange juice" into the app, it will create a marker on a floorplan of the store. In this way I want to be able to populate a map with markers that correspond to items in a grocery list. Users can then walk around the store and swipe off markers as they pick up the items.
Does anyone know how I could do this? Are there any open source Android apps currently out there I could look at?
I feel like this would be a fairly simple project involving just uploading a .jpeg into an app and assigning coordinates to classes of items, like "juice" to {20,30} or something like that, but I have very little programming experience and am lost as to how to start.
bump
Well, people normally do not get an answer if they ask how to do the whole app.
So try to find the solution yourself and ask the community if you've got more specific questions/problems.
nikwen said:
Well, people normally do not get an answer if they ask how to do the whole app.
So try to find the solution yourself and ask the community if you've got more specific questions/problems.
Click to expand...
Click to collapse
Yeah I realize that I'm not going to get a step by step process... but I was just asking for general advice. Somebody suggested I use a .shp file and use an overlay with all the markers corresponding to the items, then create a pop up marker event for every time the user selects an item, which was helpful.
I'm looking for general ideas on implementation, that's all.
justinyeh said:
Yeah I realize that I'm not going to get a step by step process... but I was just asking for general advice. Somebody suggested I use a .shp file and use an overlay with all the markers corresponding to the items, then create a pop up marker event for every time the user selects an item, which was helpful.
I'm looking for general ideas on implementation, that's all.
Click to expand...
Click to collapse
You could save the name and the coordinates to files using JSON which can easily be written manually.
Have a look at Google's gson library.

Practice App Ideas

I am new to Android App development. I need some simple application ideas to practice. please give me some ideas. I just made Rock, Paper, Scissor game. So easy games like this will be fine(I think )
Build a notepad app that lets you write and save notes. Build it steps where you increase the difficulty as you go on:
Make an app with a textbox that lets you enter text
Add a save button and learn how to execute code when the button is hit. Whenever you encounter any problems or don't know what to do, use Google! There are a lot of other running the same path as you and me who have encountered problems. The solution is almost always a search away!
Implement a save function that saves the content when the button is hit. When the user reopens the app load the text file and put the content in the textbox. Tip: Use SharedPreferences
Time to add support for multiple notes! Start off by learning how to move between activities (windows), in your notepad app add a button labeled "All notes" that sends you to another activity when clicked. Use Google to finds articles on how to do this.
Once you've figured out how to move between windows, it's time to create a list with all the notes. To display a list you use ListViews, before jumping in to showing the actual notes create a mock list containing your favorite cars, cats, Justin Bieber songs, whatever! Once you get a hang of it, move on to the next step
Learn how to store multiple strings instead of just one. Check out JSON, it's a simple data structure that lets you store.. data. Tip: store the notes in JSONObjects in a JSONArray. The final JSON-string can be stored in SharedPreferences.
Once you get a grip of JSON, add an add button, preferably in the ActionBar, that lets you add notes. Save the new note in the JSONArray.
Replace the cars or cats that are currently shown by the created lists.
VoilĂ , you have a fully functional notepad app and you've learned how to: move between activities, store data, ListViews, find solutions with Google etc. Good luck!
What are you aiming for, eventually ? Do you want to be a game developer, utility developer, are you aiming for a job developing apps ?
That might help you decide what kind of test apps to make.
If you go for a game you could spend a fair bit of time dealing with the graphical elements and gameplay without understanding the basics... so before you do that I'd suggest getting familiar with the building blocks (Activity, Intent, Service, Handler, Looper and so on) first.
jokernw said:
I am new to Android App development. I need some simple application ideas to practice. please give me some ideas. I just made Rock, Paper, Scissor game. So easy games like this will be fine(I think )
Click to expand...
Click to collapse
I started with memory game, you can go for it as well

[Q] How to run multiple processes at exactly the same time

I can not publish any code or any logs, because there is no real problem yet. I am a beginner in Android / Java and the OOP concept.
I need to run two processes at exactly the same time in my program. The processes are sound samples and requires played at exactly the same time to be synchronized with each other.
I call the methods on the lines one after the other, which gives me a delay when the first clip starts a few microseconds before. Depending on the hardware this delay will also vary enormously .. how do i run the commands, or call the methods exactly the same time?
I've been looking at adding a delay of the first method by a handler, but I do not want to do this but it does not guarantee accurate synchronization.
I am on track to use AsyncTask, and somehow run these processes simultaneously but in different threads ... I have no idea if I'm on the right track? Can anyone confirm that this is the right way, or provide information about what else I can do? Grateful for all the help I can get. I hope I have not used the wrong terms and that I have given you enough information so that you can understand my question. Thanks in advance.
Having two functions tied to the same event has worked for me in the past.
For example, if you have a play button and you set up two separate functions to run when that button is clicked, they should go at the exact same time. If your play button is pressed, it will fire both functions simultaneously.
Another more advanced approach would be to return the current time code of "sound a" and pause it until the time code of "sound b" reaches the current time of "sound a".
Im Saint said:
Having two functions tied to the same event has worked for me in the past.
For example, if you have a play button and you set up two separate functions to run when that button is clicked, they should go at the exact same time. If your play button is pressed, it will fire both functions simultaneously.
Another more advanced approach would be to return the current time code of "sound a" and pause it until the time code of "sound b" reaches the current time of "sound a".
Click to expand...
Click to collapse
Well "simultaneously" is a big word but you are right, even if one player lags behind the other one, we are talking about microseconds at most. And i doubt that anybody would even notice that.
And to OP:
In java there is a keyword called "synchronized" where one thread awaits the other. I have never used that and so i dont know how to use this. Maybe if you look it up on google it could prove useful to your project. But i actually dont think that you can technically accomplish this "true" synchronization you are thinking of... It is worth a try at least
--------------------
Phone: Nexus 4
OS: rooted Lollipop LRX21T
Bootloader: unlocked
Recovery: TWRP 2.8.2.0
Have you considered buffering? you can buffer samples in some queue and start playing them after a decided delay / samples count, making sure you have samples from all the sources you need to synchronize
Thanks for the replies, any help is much appreciated!
Im Saint said:
Having two functions tied to the same event has worked for me in the past.
For example, if you have a play button and you set up two separate functions to run when that button is clicked, they should go at the exact same time. If your play button is pressed, it will fire both functions simultaneously.
Another more advanced approach would be to return the current time code of "sound a" and pause it until the time code of "sound b" reaches the current time of "sound a".
Click to expand...
Click to collapse
Good to hear, but can it be guaranteed that the function calls are performed exactly the same time? This is very necessary for various reasons.
Masrepus said:
Well "simultaneously" is a big word but you are right, even if one player lags behind the other one, we are talking about microseconds at most. And i doubt that anybody would even notice that.
And to OP:
In java there is a keyword called "synchronized" where one thread awaits the other. I have never used that and so i dont know how to use this. Maybe if you look it up on google it could prove useful to your project. But i actually dont think that you can technically accomplish this "true" synchronization you are thinking of... It is worth a try at least
Click to expand...
Click to collapse
This is what I also want to emphasize. With the greatness of the inner meaning of "simultaneousness", even if that someone would not notice anything, it's a necessity.
I will seriously undermine further the keyword synchronized. This sounds exactly like what I need. I will succeed and reconnect with the results!
pixeltech.dev said:
Have you considered buffering? you can buffer samples in some queue and start playing them after a decided delay / samples count, making sure you have samples from all the sources you need to synchronize
Click to expand...
Click to collapse
I have heard the word buffer before but never truly understood how it works syntactically, nor in Android / Java.
With what kind of content can this be done? All types of media, audio / picture / video? Do you have any keyword to search on or link to an example?
Invisible Algorithm said:
Thanks for the replies, any help is much appreciated!
I have heard the word buffer before but never truly understood how it works syntactically, nor in Android / Java.
With what kind of content can this be done? All types of media, audio / picture / video? Do you have any keyword to search on or link to an example?
Click to expand...
Click to collapse
Buffering is a technique where you first collect enough data (can be represented in any form but is usually done through collections) and once you have enough data you do something with it.
An example can be reading data in bytes form from one source (e.g. network channel), buffering it (storing it in some collection) and writing it to files when buffered data reaches some threshold size

Categories

Resources