I have a task to create 10 questions where a user should be able to input the answer by using a touch keypad. The user should be able to cycle through questions by pressing a button called "N" Once the the user answers all of the questions a total score out of 10 would be displayed.
Im not asking for an answer but how to approach such a task.
So far ive created a keypad consisting of numbers and i can get 1 question to work and display whether the user entered correct or incorrect information but trying to get more then 1 question to work is messing up.
I had a thought and know that i can create 10 seperate activities for 10 questions but thats slightly crazy.
Can someone give me guidance on how to approach such as task
note im pretty new to android.
Thank You
All views have a visibility attribute (android:visibility); what would look nice is every time the user presses next is to simply hide the old view and make the next one show up (Can even add a fading transition to make it look fun as well)
In XML you can set them all to android:visibility="gone" to begin with, and then in your code, set it to objectName.setVisibility(0) to make it visible, and objectName.setVisibility(8) to hide it completely again.
Here is one approach (not necessarily the best):
*Wherever your question is (hopefully a TextView), get a reference of it in your activity.
*When the user answers a question, output if it was correct or not (A toast?)
*Change the TextView to the next question
You can programmatically add and remove views. You could create an empty view with just a linear layout then add and modify the existing views as you need them.
Are you writing it as a native Android app? A web-app (HTML, Javascript) could do what you're asking, and could be turned into an native app with embedded webkit view.
Related
I want to create a crossword puzzle using android studio. the problem that I run into is I can't figure out a good way to draw the crossword puzzle the crossword
upon selecting a word from that shape. the user will access an interface that is designed specifically for that word. where to enter the answer
The problem I have is how to actually create that crossword shape, especially since I need it to be created dynamically afterwards based on the supplied data.
After 15 days of research all I can find are those possibilities:
Using Table layout with each cell representing a character. But this approach is not appropriate and not optimate and create many problems.
Using GridView with the unused cells set to be invisible. this is better but I think there is a better way than creating Grids only to set most of it to invisible.*
**I am sure there is a better way, but can't figure it out.
I know I have to give a code sample for what I have but I can't even do that till I know what approach I need to create this. If there is any suggestion to make my question clear that will be welcomed as well.
Neither. This calls for custom view for the word grid. While you can probably get it to work without one, it's going to look very amateurish, and you're going to be very hacky. Instead, you'll want a totally custom view doing its own keyboard input handling. Unless this is like a school project where looks and UX don't matter and you just need it done.
Another day, another bug...
I have three AutoCompleteTextFields with the filter overrided to get completion from my REST service, but my big problem is that the suggestions popups of those text are clickthrough... so when I've already completed one of them, any click on the suggestion popup of another will trigger the underlying ACTF, which is already filled and so show it's own popup, making impossible to select the item from the other ACTF suggestion popup.
The two screenshots here show the situation, the ACTF are the textfield hinted "Partenaire", "Contact..." and the already autocompleted one under.
On the second screenshot, I've tried to select the item over the third ACTF, and so the four first results are from the third ACTF, and the four last are from the "Partenaire" ACTF.
Is there a way to override something like onShow() for the popup and it's hiding equivalent, so I could disable the other ACTF when I type in one of them ?
I think it's a good way to solve the problem, but I am open to any other idea :)
I've forget to mention it, but the problem occur on Android and on the simulator, but iOS has not such problem.
Check that your UI has scrolling set correctly, only one container in the hierarchy can be scrollable on the Y axis. By default the Form's content pane should be scrollable on Y (unless it's a border layout).
here i want to develop an app that can run a simple quiz for psychology character test, but here i need some advice on how to show the question on the activity. Because i want to showing each question without moving to other activity.
This is my temporary layout (it's still ugly XD), but i want the question can appear on the inside of that red box. And when user press Next button, the question inside that box can changed but before it change the app has been stored the answer of previous question.
I really don't know how to use fragment or something like that.
NB. This is my mainActivity look :
For your app I would recommend not to use fragments at all, it will make your app much slower than it can be.
What I would do in your case, is only load the new question in the textbox on pressing next, and call an asynchronous function (asynctask) to perform the storage of the answer. This way the user sees no delays whatshowever.
If getting the next question required a server connection, use a progress dialog in between to show the user something happens.
Agree with Bas van Stein, using different fragments will slow down the app. What you could do is separate frequently changing part of your screen (e.g. question with answer options) into a fragment and reload it's data on Next/Answer button click. This will separate the code and make it easier to maintain and change it later.
On the other hand you could do it in the activity itself if you don't want to use fragment.
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.
I apologize if I'm just missing the obvious. I'm fairly new to Android development, and while I searched for this particular topic, I wasn't exactly sure what to look for (in terms of a "name").
In an application I'm writing, I have a section where the user can enter the names of players. However, this can range anywhere from 1 to whatever, no limit. However, I'm not sure what the best approach for this kind of feature is, or if there's a component that already does something like it.
Basically, the functionality I'm looking for is similar to what you can see in the Edit Contact screen of the phone book; for the phone numbers and email addresses, you can push a little plus button to add a new number/address, or hit the little minus button to remove a number/address.
I can think of several ways to potentially implement this, but in the end I think wrapping it in a custom component would be best (so that you could call "Get Players" and have it return a list of strings by going through each of the inputs and getting the values).
Am I just overthinking this? Is there a component that does that already? Is there some example code that demonstrates a good way to do this?
Thanks!
Could you just use ListView and add a menu with a "Add Players" option? You could customize the list view to have a little checkbox, for example, and then begin the game by pressing the menu ... or add new players dynamically by pressing another menu button.
After playing around with some ideas, I came across a solution that I think will suit what I'm doing. I created a custom component extending LinearLayout. As part of the creation of the component, it creates a row that says "Add new..." with a plus-sign button. Pressing the plus sign button then creates a new row containing an EditText and a minus-button which will remove the row.
I then created a method for this component called getTexts() which returns a List that has all the non-empty Text values from all the components. Testing it in a dummy app, it seemed to work fine.
I think I need to make tweaks to make it more robust (like the ability to add rows programatically, listeners to alert other components when a row is added/removed, and the ability to set the individual EditText values, for instance), but this functions as I imagined.