Android: How to implement quiz app [closed] - android

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to implement an Android app which includes a part where user can do a quiz. Since I'm kinda new to Android app development, I would like some advice on how to implement the quiz part, in terms of layout
I have a set of questions and each has their own respective choice of answers from which I retrieve from my API.
What is the best and easy to implement approach to do this? I need to display each question page by page (Q1 -> Q2 -> ...).
Do I generate a set of Fragments? Or do I somehow use RecyclerView to generate each page for each question?
Any guidance would be greatly appreciated, thanks!

This is kind of a broad question, but here are some quick ideas to get you started.
Off the top of my head, you could have an activity called QuestionActivity (or whatever you want), which would be the main container to display questions. You would then have a QuestionFragment which would be displayed inside the QuestionActivity. Each time you want to display a new question, you would call the Fragment's newInstance() method, passing in the appropriate data in a Bundle each time to populate the layout of the Fragment, then replacing the Fragment in the Activity using a fragment transaction.
As for the Fragment itself, you could maybe do a LinearLayout, with a TextView at the top to display the question, a set of RadioButtons below that, to show some multiple choice options, then a submit Button under that, which the user would use to submit his answer. Then of course you would receive all the click events for these things to determine which answer was selected, etc.
Your QuestionFragment layout might start with something like this...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.david.timedtask.QuizActivity">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/quiz_question"
android:id="#+id/textView"
android:layout_gravity="center_horizontal"
android:paddingBottom="100dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option_one"
android:id="#+id/radioButton" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option_two"
android:id="#+id/radioButton2" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option_three"
android:id="#+id/radioButton3" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option_four"
android:id="#+id/radioButton4" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/submit_button"
android:id="#+id/button"
android:layout_marginTop="50dp"/>
</LinearLayout>
</RelativeLayout>
And this would produce a result looking something like this...
Of course this is all pretty basic, but again, your question was pretty broad. There are plenty of docs available to show you how to actually code all this stuff and put it all together, but hopefully this will get you started.
Good luck!

I don't know what kind of view do you use to show first quiz question but every next question should be shown in same view by changing values of current controls.

Related

Android: Any Ideas on how to make a Hearthstone/Magicka type of card? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Details:
I was wondering how to create an object in android that has multiple layers of graphical elements. A good example would be a Magicka or Hearthstone card. They have 3 elements: the background of the card, the image of the creature, text describing something + stats.
The idea behind this is to have fewer images that can be put together to create a great amount of cards. I should mention that in my case the background card and the creature are vectors (SVG).
How do you put all of these elements together in one card-thing that can later be displayed&animated?
You can use proper layout.
Most reasonable to me is using RelativeLayout.
You can put all views:
background (can be a separate view or background view param)
image (ImageView)
text (TextView)
For example:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="160dp"
android:layout_height="240dp"
android:background="#color/aaa">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:src="#drawable/cat_filmy_main" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:text="Movie Killer" />
</RelativeLayout>
And the effect is:
Also, consider creating your own view. How to do that can be found here:
https://code.tutsplus.com/tutorials/android-sdk-creating-custom-views--mobile-14548

What should I do in this case? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have antwo fragments like this:
What I want is when I press the "MapView" button, the whole screen will be like this:
so what should I do in this case to have the best UX? should I turn two fragments off and add a new one? Pleases give me some ideas! Thank you!
It's better to convert the whole stuff into 4 fragments.
Fragment 1: Search Bar
Fragment 2: Two Buttons
Fragment 3: Bottom list
Fragment 4: The map
So in this case you can listen to click on each button and replace the corresponding container having fragment 3 with fragment 4. If your design requires to hide fragment 1, it could also be done in this case.
I recommend to use a PagerTitleStrip layout. Just replace the content below the title strip by a fragment transaction. Feel free to ask, if you need further information (how to set it up).
A good starting point are the docs, the guidelines and maybe this tutorial.
Btw: one of my apps does a similar job, have a look: Libre Drive
You need to have a parent layout which will have two buttons at top. MapView and List View. Then Display desired Fragment with click on button through java code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="MapView" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="ListView" />
<fragment
android:name="com.example.app.myFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout="#layout/my_fragment"
/>
</LinearLayout>

Android Top and Bottom menu [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am new in Android and i don't have much programming knowledge. I want to create top and bottom menus for my android app. i have attached a sample image. Please someone help me
There are two possibilities of how you can achieve something like that:
1) Use a split ActionBar (more information on the ActionBar)
2) You can define it yourself inside an XML-layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/top_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</LinearLayout>
<!-- Your page-content can go here -->
<LinearLayout
android:id="#+id/bottom_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
</LinearLayout>
</RelativeLayout>
Design two custom layout xml one for top menu bar and one for bottom menu bar. And include these xml file in your main xml. Then call the button in custom xml same as calling from main xml in the java file.

Simple non interactive ListView Android

Please cope with me as im new to android and i have done a lot of searching on my own, about this, and im fed up not finding a proper way.
This is my custom listview template. rowbuttonlayout.xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#+id/label"
android:textSize="19.6dp" >
</TextView>
<CheckBox
android:id="#+id/check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="3.6dp"
android:layout_marginRight="9.6dp" >
</CheckBox>
<TextView
android:id="#+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/check"
android:layout_alignBottom="#+id/check"
android:layout_toLeftOf="#+id/check"
android:text="#string/nothing" />
</RelativeLayout>
What i want is to create something like this in this pic without the header and footer.
http://www.vogella.com/articles/AndroidListView/images/xinteractive10.png.pagespeed.ic.V0cVgp99SN.png
As on my layout ill be having another textview just before the checkbox as well. Also ill be adding a dynamic button at the footer.
Now i dont want the users to interact with my listview. Only the button should be clickable and when they click it i want to run some calculations and show them in the relevant "result" textview and to check the checkbox next to it to show that i have calculated it. Meaning i have to access each and every "result" textview and "check" checkbox in the code.
Please provide me some guidance for coding this app. Im fed up looking through very complex codes trying learn on my own. Many many thanks for your help.
Shavinka
Check out below links...
ListView + CheckBox =?
How to get checked items from android listview?
http://sunil-android.blogspot.in/2013/04/android-listview-checkbox-example.html
http://fundoocode.net/android-listview-checkbox-example-onitemclicklistener-and-onclicklistener/
http://www.mysamplecode.com/2012/07/android-listview-checkbox-example.html

How to handle click events on a drawable within an TextView? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have the same problem as discussed on Handling click events on a drawable within an EditText, but I use TextView instead of EditText. When I click on the TextView, the method onTouchEvent(MotionEvent event) is called. Is it possible to handle a click only on the icon?
I think the idea is pretty much the same as described here: use the event coordinates and determine if they are within the drawable's bounds. If they are, perform your action. I don't think there are any major differences between TextView and EditText in this respect.
I think that it would be a better idea to use a TextView and an ImageView. Of course, it leads to a more complex layout structure, but I'd prefer two widgets in an XML file rather than too much Java code dealing with the widgets.
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/iv"
android:text="#string/long_text"
android:textSize="22sp" />
<ImageView
android:id="#id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:contentDescription="#string/app_name"
android:src="#drawable/btn_go" />

Categories

Resources