SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
Android Quiz App Tutorial 
Step 1: Define a RelativeLayout 
Create a new android application and use the default settings. You will 
have a base app that uses a relative layout already.
A RelativeLayout is a flexible layout that allows you to organize UI 
elements in relation to one another, making it particularly useful for 
developers who need fine-grained control over the exact positioning of 
their UI components. 
Step 2: Designing for Multiple Screens: Background Image 
As an open source operating system, Android crops up on all sorts of 
devices, and is the OS of choice for many different manufacturers – it’s 
no longer even restricted to smartphones! This presents both exciting 
opportunities and headache-inducing challenges for Android 
developers. When developing your UI, keep in mind that your app 
needs to display correctly across as many devices as possible. While 
designing for multiple screens is too broad a topic for this tutorial, as a 
starting point you should provide alternate versions of every image 
used in your app. These alternate images should be optimized for 
screens with different pixel densities. When your app launches, 
Android will automatically load the correct image based on the device’s 
display characteristics.
Open the ‘res’ folder and you will see five drawable folders that Eclipse 
generates by default: 
• drawable-ldpi 
• drawable-mdpi 
• drawable-hdpi 
• drawable-xhdpi 
• drawable-xxhdpi 
These folders target screens with different pixel densities, following a 
3:4:6:8 scaling ratio (for example, if drawable-ldpi contains an image 
of 36 x 36 pixels, then drawable-mdpi should contain an image of 48 x 
48 pixels, and so on). 
Create four versions of your background image based on this ratio, 
and drag each version into the appropriate folder. 
Add the background image to RelativeLayout using the 
‘android:background’ attribute, referring to the image resource as you 
would any drawable object: 
android:background="@drawable/background" 
The layout should not look something like this:
Run your app and let’s see what we have so far. Hopefully your screen 
looks something like this: 
Step 3: Creating ImageButtons
The first step of creating an ImageButton is to add the required 
images to your project. Again, because you want your device to 
display correctly across a range of screens, you should provide four 
versions of each image. We’ll start with the ‘2003’ button, so drag and 
drop the five versions of your ‘2003’ image into the corresponding 
folders. 
ImageButtons are created using the ‘ImageButton’ tag followed by the 
usual height/width attributes, and some RelativeLayout-specific 
alignment attributes. Create your first ImageButton and tweak the 
alignment until you’re happy with how it’s positioned. 
<ImageButton 
android:id="@+id/imageButton1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_centerHorizontal="true" 
android:layout_centerVertical="true"
android:src="@drawable/button2003" /> 
Check how this appears in the emulator. 
Repeat this process for the other four buttons. This is a good 
opportunity to experiment with the various RelativeLayout attributes 
As you fine-tune your layout, you may find it useful to keep the 
emulator open, switching between it, the graphical layout editor and 
your XML. 
Here’s the finished Activity_Main.xml layout file:
<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:background="@drawable/background" > 
<ImageButton 
android:id="@+id/imageButton1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_centerHorizontal="true" 
android:layout_centerVertical="true" 
android:src="@drawable/button2003" /> 
<ImageButton 
android:id="@+id/imageButton2" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_below="@+id/imageButton1" 
android:layout_centerHorizontal="true" 
android:src="@drawable/button2004" /> 
<ImageButton 
android:id="@+id/imageButton3" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_below="@+id/imageButton2" 
android:layout_centerHorizontal="true" 
android:src="@drawable/button2005" /> 
<ImageButton 
android:id="@+id/imageButton4" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_below="@+id/imageButton3" 
android:layout_centerHorizontal="true" 
android:src="@drawable/button2006" /> 
</RelativeLayout> 
Run your app again and make sure you like the look of the layout so 
far:
The buttons may be displaying correctly in the emulator, but Eclipse is 
probably throwing multiple “Missing contentDescription attribute on 
image” errors. 
Step 4: Making Your App Accessible 
The ContentDescrition attribute makes applications more accessible to 
users who cannot easily consume graphical content, by providing an 
alternate text description. This description can be used by screen 
readers and similar accessibility tools.
The first step is to define some new string resources. Strings are 
defined in the res/layout/strings.xml file, so open it and switch to the 
strings.xml tab if necessary. 
String resources are created with the following syntax: 
<string name="name">Text to display</string> 
Define a string for the ContentDescription of each ImageButton as 
follows: 
<string name="button2003">Answer 2003</string> 
<string name="button2004">Answer 2004</string> 
<string name="button2005">Answer 2005</string> 
<string name="button2006">Answer 2006</string> 
Return to your activity_main.xml file and add a ContentDescription 
attribute to each of the ImageButtons as follows: 
Add to each button: 
android:contentDescription="@string/button2003” 
Do this for all of the buttons and change the names to the correct 
button images. 
Step 5: Creating Stylish Text 
In reality, it’s unlikely you’ll cease developing an app at Version 1.0, as 
you cook up new content and release fixes for any pesky bugs that 
users discover. Therefore, it’s handy if people can tell at a glance what 
version of your app they’re running. The easiest way to do this is with 
a TextView. 
Open the strings.xml file and define the current version number as a 
string: 
<string name="Version">Version 1.0</string> 
You can quickly create a TextView that calls “@string/Version” but 
Android’s default text style isn’t particularly appealing. Thankfully,
TextView has a range of attributes that can give boring old text some 
style. In this tutorial we’ll use the following: 
• android:textColor – sets the color of your text. It can either be 
defined as a string resource, or as a color value. 
• android:textSize – sets the text size, which can be given either 
as px (pixels) sp (scaled pixels) dp (density-independent pixels) 
in (inches) or mm (millimeters) 
• android:textStyle – either italic or bold. 
Open your Activity_Main.xml file and create your TextView, add 
some style attributes, and then reference the “Version” string: 
<TextView 
android:id="@+id/textView1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_alignParentBottom="true" 
android:layout_alignParentLeft="true" 
android:layout_marginLeft="26dp" 
android:paddingBottom="5dp" 
android:text="@string/Version" 
android:textColor="#f7f9f6" 
android:textSize="13dp" 
android:textStyle="italic" /> 
You should now see the version information in the lower part of the 
screen as follows:
This works, but if you’re planning to re-use this set of attributes 
elsewhere then you should define it as a custom “Style.” A style is a 
time-saving collection of properties (in this case font color, font size, 
and the italic style) that specifies the appearance of a view, or even an 
entire application. 
You’ll often hear ‘styles’ and ‘themes’ mentioned in a similar context. 
Essentially, the only difference between a style and a theme is their 
scope: ‘styles’ that are applied to activities become ‘themes.’ 
To define a custom style: 
1. Open the res/values/styles.xml file, ensure it has opening 
and closing ‘resource’ tags, and give your style a unique name 
and define all the attributes that belong to this style: 
<style name="VersionFont"> 
<item name="android:textColor">#f7f9f6</item> 
<item name="android:textSize">13dp</item> 
<item name="android:textStyle">italic</item> 
</style> 
Applying this custom style to your TextView is easy, simply replace all 
the attributes defined by the VersionFont style, with: 
style="@style/VersionFont". For example:
<TextView 
android:id="@+id/textView1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_alignParentBottom="true" 
android:layout_alignParentLeft="true" 
android:layout_marginLeft="26dp" 
android:paddingBottom="5dp" 
android:text="@string/Version" 
style="@style/VersionFont" /> 
This custom style isn’t defined in the Android namespace, which is why 
we don’t need to include an “android:” reference. 
Both of these methods are valid ways of styling text, but keep in mind 
that a custom style can speed up the coding process if you’re going to 
re-use the same collection of attributes across your application. 
Step 6: Making Your App Interactive 
Your UI may be finished, but there’s one final step: letting the user 
know whether they’ve selected the correct answer. The easiest way to 
make buttons ‘tappable’ is by implementing the android:onClick 
property for each button. 
We’ll start by adding it to the first button: 
Add for each botton: 
android:onClick="onClick2003" 
Change the name of the event to match each of the years. 
The name of the onClick method must correspond to a public method 
in the MainActivity.Java file. Now we need to specify the behavior that 
“onClick2003″ triggers. A straightforward way of telling the user 
they’ve got the question wrong, is with a toast notification. 
Add the following method to MainActivity.java:
public void onClick2003 (View view) 
{ 
Toast.makeText(this, "Wrong! Try again", 
Toast.LENGTH_SHORT).show(); 
} 
Run this updated code in the emulator and get clicking to check your 
toast is firing properly. 
Success! 
Add the onClick method for the other three buttons and create 
corresponding public methods in your Activity, with appropriate 
messages attached. Once you’ve finished, boot up the emulator and 
have a click around to check everything’s working okay.
The finished method set looks like this: 
public void onClick2003 (View view) 
{ 
Toast.makeText(this, "Wrong! Try again", 
Toast.LENGTH_SHORT).show(); 
} 
public void onClick2004 (View view) 
{ 
Toast.makeText(this, "Wrong! Try again", 
Toast.LENGTH_SHORT).show(); 
}
public void onClick2005 (View view) 
{ 
Toast.makeText(this, "Yes! Well done :)", 
Toast.LENGTH_SHORT).show(); 
} 
public void onClick2006 (View view) 
{ 
Toast.makeText(this, "Wrong! Try again", 
Toast.LENGTH_SHORT).show(); 
} 
Conclusion 
Over the course of this tutorial you’ve learned the essentials of Android 
UI design and created a simple, but effective UI that has some 
working functionality to boot! Try applying some of these techniques to 
your own Android projects, to ensure your UI doesn’t let your app 
down.

Weitere ähnliche Inhalte

Was ist angesagt?

Simple Android Project (SAP)... A Test Application
Simple Android Project (SAP)... A Test ApplicationSimple Android Project (SAP)... A Test Application
Simple Android Project (SAP)... A Test ApplicationAritra Mukherjee
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Ahsanul Karim
 
java mini project for college students
java mini project for college students java mini project for college students
java mini project for college students SWETALEENA2
 
Sensors in Android (old)
Sensors in Android (old)Sensors in Android (old)
Sensors in Android (old)Ahsanul Karim
 
Android application project presentation.
Android application project presentation.Android application project presentation.
Android application project presentation.Eyakub Sorkar
 
Time Table Reminder Andorid App SRS
Time Table Reminder Andorid App SRSTime Table Reminder Andorid App SRS
Time Table Reminder Andorid App SRSAnjali Agrawal
 
Lecture #1 Creating your first android project
Lecture #1  Creating your first android projectLecture #1  Creating your first android project
Lecture #1 Creating your first android projectVitali Pekelis
 
Creating Intelligent Chatbots
Creating Intelligent ChatbotsCreating Intelligent Chatbots
Creating Intelligent ChatbotsKevin Leung
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAhsanul Karim
 
Beta testing guidelines for developer
Beta testing guidelines for developerBeta testing guidelines for developer
Beta testing guidelines for developerKetan Raval
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedAhsanul Karim
 
Unit 2 - Introduction to UIKit
Unit 2 - Introduction to UIKitUnit 2 - Introduction to UIKit
Unit 2 - Introduction to UIKitFranco Cedillo
 
android layouts
android layoutsandroid layouts
android layoutsDeepa Rani
 
What are accessible names and why should you care?
What are accessible names and why should you care?What are accessible names and why should you care?
What are accessible names and why should you care?Russ Weakley
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outletsveeracynixit
 

Was ist angesagt? (20)

Android Services
Android ServicesAndroid Services
Android Services
 
Simple Android Project (SAP)... A Test Application
Simple Android Project (SAP)... A Test ApplicationSimple Android Project (SAP)... A Test Application
Simple Android Project (SAP)... A Test Application
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3
 
java mini project for college students
java mini project for college students java mini project for college students
java mini project for college students
 
Sensors in Android (old)
Sensors in Android (old)Sensors in Android (old)
Sensors in Android (old)
 
Android application project presentation.
Android application project presentation.Android application project presentation.
Android application project presentation.
 
Time Table Reminder Andorid App SRS
Time Table Reminder Andorid App SRSTime Table Reminder Andorid App SRS
Time Table Reminder Andorid App SRS
 
Training android
Training androidTraining android
Training android
 
Lecture #1 Creating your first android project
Lecture #1  Creating your first android projectLecture #1  Creating your first android project
Lecture #1 Creating your first android project
 
Creating Intelligent Chatbots
Creating Intelligent ChatbotsCreating Intelligent Chatbots
Creating Intelligent Chatbots
 
Android Layout.pptx
Android Layout.pptxAndroid Layout.pptx
Android Layout.pptx
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver Tutorial
 
Beta testing guidelines for developer
Beta testing guidelines for developerBeta testing guidelines for developer
Beta testing guidelines for developer
 
Srs for project
Srs for projectSrs for project
Srs for project
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting Started
 
Unit 2 - Introduction to UIKit
Unit 2 - Introduction to UIKitUnit 2 - Introduction to UIKit
Unit 2 - Introduction to UIKit
 
android layouts
android layoutsandroid layouts
android layouts
 
Android app development guide for freshers by ace web academy
Android app development guide for freshers  by ace web academyAndroid app development guide for freshers  by ace web academy
Android app development guide for freshers by ace web academy
 
What are accessible names and why should you care?
What are accessible names and why should you care?What are accessible names and why should you care?
What are accessible names and why should you care?
 
Ios actions and outlets
Ios actions and outletsIos actions and outlets
Ios actions and outlets
 

Andere mochten auch

Android quiz app presentation
Android quiz app presentationAndroid quiz app presentation
Android quiz app presentationlitayem bechir
 
Online Quiz System Project PPT
Online Quiz System Project PPTOnline Quiz System Project PPT
Online Quiz System Project PPTShanthan Reddy
 
Android app presentation
Android app presentation Android app presentation
Android app presentation Maxpromotion
 
Online examination system project ppt
Online examination system project pptOnline examination system project ppt
Online examination system project pptMohit Gupta
 
Project report of OCR Recognition
Project report of OCR RecognitionProject report of OCR Recognition
Project report of OCR RecognitionBharat Kalia
 
My Project Report Documentation with Abstract & Snapshots
My Project Report Documentation with Abstract & SnapshotsMy Project Report Documentation with Abstract & Snapshots
My Project Report Documentation with Abstract & SnapshotsUsman Sait
 
SRS for online examination system
SRS for online examination systemSRS for online examination system
SRS for online examination systemlunarrain
 
Final Year Project Presentation
Final Year Project PresentationFinal Year Project Presentation
Final Year Project PresentationSyed Absar
 

Andere mochten auch (13)

Android Quiz
Android QuizAndroid Quiz
Android Quiz
 
Android quiz app presentation
Android quiz app presentationAndroid quiz app presentation
Android quiz app presentation
 
Online Quiz System Project PPT
Online Quiz System Project PPTOnline Quiz System Project PPT
Online Quiz System Project PPT
 
Android app presentation
Android app presentation Android app presentation
Android app presentation
 
Online examination system project ppt
Online examination system project pptOnline examination system project ppt
Online examination system project ppt
 
Java project-presentation
Java project-presentationJava project-presentation
Java project-presentation
 
Project report of OCR Recognition
Project report of OCR RecognitionProject report of OCR Recognition
Project report of OCR Recognition
 
Android presentation slide
Android presentation slideAndroid presentation slide
Android presentation slide
 
Project explation ppt
Project explation pptProject explation ppt
Project explation ppt
 
My Project Report Documentation with Abstract & Snapshots
My Project Report Documentation with Abstract & SnapshotsMy Project Report Documentation with Abstract & Snapshots
My Project Report Documentation with Abstract & Snapshots
 
SRS for online examination system
SRS for online examination systemSRS for online examination system
SRS for online examination system
 
Final Year Project Presentation
Final Year Project PresentationFinal Year Project Presentation
Final Year Project Presentation
 
Online quiz system
Online quiz systemOnline quiz system
Online quiz system
 

Ähnlich wie Ap quiz app

Android Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectAndroid Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectJoemarie Amparo
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in androidMahmudul Hasan
 
Android Tutorials : Basic widgets
Android Tutorials : Basic widgetsAndroid Tutorials : Basic widgets
Android Tutorials : Basic widgetsPrajyot Mainkar
 
01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgetsSiva Kumar reddy Vasipally
 
Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1Joemarie Amparo
 
Building a simple user interface lesson2
Building a simple user interface lesson2Building a simple user interface lesson2
Building a simple user interface lesson2Kalluri Vinay Reddy
 
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & MenusLearn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & MenusEng Teong Cheah
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1Isham Rashik
 
Android Development
Android DevelopmentAndroid Development
Android DevelopmentDaksh Semwal
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-TejamFandat
 
Android Development project
Android Development projectAndroid Development project
Android Development projectMinhaj Kazi
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAhsanul Karim
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_programEyad Almasri
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Appcelerator Titanium Kinetic practices part 1
Appcelerator Titanium Kinetic practices part 1Appcelerator Titanium Kinetic practices part 1
Appcelerator Titanium Kinetic practices part 1フ乇丂ひ丂
 

Ähnlich wie Ap quiz app (20)

Android Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectAndroid Development Made Easy - With Sample Project
Android Development Made Easy - With Sample Project
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in android
 
Android Tutorials : Basic widgets
Android Tutorials : Basic widgetsAndroid Tutorials : Basic widgets
Android Tutorials : Basic widgets
 
01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgets
 
Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1Android Development for Beginners with Sample Project - Day 1
Android Development for Beginners with Sample Project - Day 1
 
Building a simple user interface lesson2
Building a simple user interface lesson2Building a simple user interface lesson2
Building a simple user interface lesson2
 
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & MenusLearn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 
Android Development
Android DevelopmentAndroid Development
Android Development
 
mobile application development -unit-3-
mobile application development  -unit-3-mobile application development  -unit-3-
mobile application development -unit-3-
 
Android ui with xml
Android ui with xmlAndroid ui with xml
Android ui with xml
 
Android Development project
Android Development projectAndroid Development project
Android Development project
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_program
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Android
AndroidAndroid
Android
 
Appcelerator Titanium Kinetic practices part 1
Appcelerator Titanium Kinetic practices part 1Appcelerator Titanium Kinetic practices part 1
Appcelerator Titanium Kinetic practices part 1
 
Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
 

Kürzlich hochgeladen

一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制pxcywzqs
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样ayvbos
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdfMatthew Sinclair
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfJOHNBEBONYAP1
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasDigicorns Technologies
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.krishnachandrapal52
 
75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptxAsmae Rabhi
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsMonica Sydney
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxgalaxypingy
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHenryBriggs2
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查ydyuyu
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoilmeghakumariji156
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtrahman018755
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftAanSulistiyo
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsMonica Sydney
 
Power point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria IuzzolinoPower point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria Iuzzolinonuriaiuzzolino1
 

Kürzlich hochgeladen (20)

一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
 
Power point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria IuzzolinoPower point inglese - educazione civica di Nuria Iuzzolino
Power point inglese - educazione civica di Nuria Iuzzolino
 

Ap quiz app

  • 1. Android Quiz App Tutorial Step 1: Define a RelativeLayout Create a new android application and use the default settings. You will have a base app that uses a relative layout already.
  • 2. A RelativeLayout is a flexible layout that allows you to organize UI elements in relation to one another, making it particularly useful for developers who need fine-grained control over the exact positioning of their UI components. Step 2: Designing for Multiple Screens: Background Image As an open source operating system, Android crops up on all sorts of devices, and is the OS of choice for many different manufacturers – it’s no longer even restricted to smartphones! This presents both exciting opportunities and headache-inducing challenges for Android developers. When developing your UI, keep in mind that your app needs to display correctly across as many devices as possible. While designing for multiple screens is too broad a topic for this tutorial, as a starting point you should provide alternate versions of every image used in your app. These alternate images should be optimized for screens with different pixel densities. When your app launches, Android will automatically load the correct image based on the device’s display characteristics.
  • 3. Open the ‘res’ folder and you will see five drawable folders that Eclipse generates by default: • drawable-ldpi • drawable-mdpi • drawable-hdpi • drawable-xhdpi • drawable-xxhdpi These folders target screens with different pixel densities, following a 3:4:6:8 scaling ratio (for example, if drawable-ldpi contains an image of 36 x 36 pixels, then drawable-mdpi should contain an image of 48 x 48 pixels, and so on). Create four versions of your background image based on this ratio, and drag each version into the appropriate folder. Add the background image to RelativeLayout using the ‘android:background’ attribute, referring to the image resource as you would any drawable object: android:background="@drawable/background" The layout should not look something like this:
  • 4. Run your app and let’s see what we have so far. Hopefully your screen looks something like this: Step 3: Creating ImageButtons
  • 5. The first step of creating an ImageButton is to add the required images to your project. Again, because you want your device to display correctly across a range of screens, you should provide four versions of each image. We’ll start with the ‘2003’ button, so drag and drop the five versions of your ‘2003’ image into the corresponding folders. ImageButtons are created using the ‘ImageButton’ tag followed by the usual height/width attributes, and some RelativeLayout-specific alignment attributes. Create your first ImageButton and tweak the alignment until you’re happy with how it’s positioned. <ImageButton android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true"
  • 6. android:src="@drawable/button2003" /> Check how this appears in the emulator. Repeat this process for the other four buttons. This is a good opportunity to experiment with the various RelativeLayout attributes As you fine-tune your layout, you may find it useful to keep the emulator open, switching between it, the graphical layout editor and your XML. Here’s the finished Activity_Main.xml layout file:
  • 7. <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:background="@drawable/background" > <ImageButton android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/button2003" /> <ImageButton android:id="@+id/imageButton2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/imageButton1" android:layout_centerHorizontal="true" android:src="@drawable/button2004" /> <ImageButton android:id="@+id/imageButton3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/imageButton2" android:layout_centerHorizontal="true" android:src="@drawable/button2005" /> <ImageButton android:id="@+id/imageButton4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/imageButton3" android:layout_centerHorizontal="true" android:src="@drawable/button2006" /> </RelativeLayout> Run your app again and make sure you like the look of the layout so far:
  • 8. The buttons may be displaying correctly in the emulator, but Eclipse is probably throwing multiple “Missing contentDescription attribute on image” errors. Step 4: Making Your App Accessible The ContentDescrition attribute makes applications more accessible to users who cannot easily consume graphical content, by providing an alternate text description. This description can be used by screen readers and similar accessibility tools.
  • 9. The first step is to define some new string resources. Strings are defined in the res/layout/strings.xml file, so open it and switch to the strings.xml tab if necessary. String resources are created with the following syntax: <string name="name">Text to display</string> Define a string for the ContentDescription of each ImageButton as follows: <string name="button2003">Answer 2003</string> <string name="button2004">Answer 2004</string> <string name="button2005">Answer 2005</string> <string name="button2006">Answer 2006</string> Return to your activity_main.xml file and add a ContentDescription attribute to each of the ImageButtons as follows: Add to each button: android:contentDescription="@string/button2003” Do this for all of the buttons and change the names to the correct button images. Step 5: Creating Stylish Text In reality, it’s unlikely you’ll cease developing an app at Version 1.0, as you cook up new content and release fixes for any pesky bugs that users discover. Therefore, it’s handy if people can tell at a glance what version of your app they’re running. The easiest way to do this is with a TextView. Open the strings.xml file and define the current version number as a string: <string name="Version">Version 1.0</string> You can quickly create a TextView that calls “@string/Version” but Android’s default text style isn’t particularly appealing. Thankfully,
  • 10. TextView has a range of attributes that can give boring old text some style. In this tutorial we’ll use the following: • android:textColor – sets the color of your text. It can either be defined as a string resource, or as a color value. • android:textSize – sets the text size, which can be given either as px (pixels) sp (scaled pixels) dp (density-independent pixels) in (inches) or mm (millimeters) • android:textStyle – either italic or bold. Open your Activity_Main.xml file and create your TextView, add some style attributes, and then reference the “Version” string: <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_marginLeft="26dp" android:paddingBottom="5dp" android:text="@string/Version" android:textColor="#f7f9f6" android:textSize="13dp" android:textStyle="italic" /> You should now see the version information in the lower part of the screen as follows:
  • 11. This works, but if you’re planning to re-use this set of attributes elsewhere then you should define it as a custom “Style.” A style is a time-saving collection of properties (in this case font color, font size, and the italic style) that specifies the appearance of a view, or even an entire application. You’ll often hear ‘styles’ and ‘themes’ mentioned in a similar context. Essentially, the only difference between a style and a theme is their scope: ‘styles’ that are applied to activities become ‘themes.’ To define a custom style: 1. Open the res/values/styles.xml file, ensure it has opening and closing ‘resource’ tags, and give your style a unique name and define all the attributes that belong to this style: <style name="VersionFont"> <item name="android:textColor">#f7f9f6</item> <item name="android:textSize">13dp</item> <item name="android:textStyle">italic</item> </style> Applying this custom style to your TextView is easy, simply replace all the attributes defined by the VersionFont style, with: style="@style/VersionFont". For example:
  • 12. <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_marginLeft="26dp" android:paddingBottom="5dp" android:text="@string/Version" style="@style/VersionFont" /> This custom style isn’t defined in the Android namespace, which is why we don’t need to include an “android:” reference. Both of these methods are valid ways of styling text, but keep in mind that a custom style can speed up the coding process if you’re going to re-use the same collection of attributes across your application. Step 6: Making Your App Interactive Your UI may be finished, but there’s one final step: letting the user know whether they’ve selected the correct answer. The easiest way to make buttons ‘tappable’ is by implementing the android:onClick property for each button. We’ll start by adding it to the first button: Add for each botton: android:onClick="onClick2003" Change the name of the event to match each of the years. The name of the onClick method must correspond to a public method in the MainActivity.Java file. Now we need to specify the behavior that “onClick2003″ triggers. A straightforward way of telling the user they’ve got the question wrong, is with a toast notification. Add the following method to MainActivity.java:
  • 13. public void onClick2003 (View view) { Toast.makeText(this, "Wrong! Try again", Toast.LENGTH_SHORT).show(); } Run this updated code in the emulator and get clicking to check your toast is firing properly. Success! Add the onClick method for the other three buttons and create corresponding public methods in your Activity, with appropriate messages attached. Once you’ve finished, boot up the emulator and have a click around to check everything’s working okay.
  • 14. The finished method set looks like this: public void onClick2003 (View view) { Toast.makeText(this, "Wrong! Try again", Toast.LENGTH_SHORT).show(); } public void onClick2004 (View view) { Toast.makeText(this, "Wrong! Try again", Toast.LENGTH_SHORT).show(); }
  • 15. public void onClick2005 (View view) { Toast.makeText(this, "Yes! Well done :)", Toast.LENGTH_SHORT).show(); } public void onClick2006 (View view) { Toast.makeText(this, "Wrong! Try again", Toast.LENGTH_SHORT).show(); } Conclusion Over the course of this tutorial you’ve learned the essentials of Android UI design and created a simple, but effective UI that has some working functionality to boot! Try applying some of these techniques to your own Android projects, to ensure your UI doesn’t let your app down.