+91-9519066910
USA: +1(715)227-4880, UK: +44-7896988486, AU:+61-452503850

Assignment

Computing Skills Assignment Help

Matlab Assignment Help

NIT6120 Mobile Applications

Rating:
NIT6120 Mobile Applications

NIT6120 Mobile Applications 

Lab 02

 

Before you start this lab, make sure you have Android Studio running with emulators or on your devices.

 

Task 1: Hello World Project 

Create a simple “Hello Android World!” Android app that prints to your device’s screen. If you do not have android devices, you may emulator. Make a small change to the app so it displays - Program written by . 

Hint: Go to Android Window, res folder -> values -> strings.xml 

Task 2: DinoQuiz Project (2 marks) 

This project is intended to make you aware about the concepts of Android Development. In addition, the app is provided with different layout elements. These are text elements (text widget), graphic elements (image widget) and buttons (button widget).

 The finished app has a single screen with one question displaying at a time. When you run an app, the first question will be displayed. You can use “Next” and “Back” buttons to navigate to next and previous questions respectively.

The App Idea

 

In the DinoQuiz app, it will test users’ knowledge about dinosaurs through questions. A question is asked and different options are provided to select an answer. The game displays a feedback message depending on whether the answer is correct or wrong. There are 5 questions in all. 

Questions are: 

Are the birds the closest relatives of dinosaurs?

The last surviving dinosaur is the sea monster Nessi.

The Jurassic Park is a sanctuary for dinosaurs.

All dinosaurs were vegetarians.

Rex was the largest dinosaur.

Next task is to add two buttons. You need to define a new Linear layout below the textview to be able to place these buttons next to each other. You can drag and drop the buttons or use xml code. 

Your final activity_main.xml file would look like this after adding all components: 

xml version="1.0" encoding="utf-8"?>

<LinearLayout 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:orientation="vertical"

tools:context="com.example.sunam.dinoquiz.MainActivity"

android:gravity="center">

 

<TextView

android:id="@+id/question_text_view"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:paddingLeft="16dp"

android:paddingRight="16dp"

android:text="@string/question_text"

android:textSize="24sp"

android:gravity="center" />

 

<LinearLayout

android:orientation="horizontal"

android:layout_width="match_parent" 

 

android:layout_height="wrap_content"

android:layout_marginTop="10dp"

android:gravity="center"> 

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/true_button"

android:id="@+id/true_button" />

 

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="@string/false_button"

android:id="@+id/false_button"/>

LinearLayout>

 

<LinearLayout

android:orientation="horizontal"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginTop="20dp"

android:gravity="center">

 

<Button

android:layout_width="100dp"

 

android:layout_height="wrap_content"

android:text="@string/prev_button"

android:layout_gravity="left"

android:id="@+id/prev_button" />

 

<Button

android:layout_width="100dp"

 

android:layout_height="wrap_content"

android:text="@string/next_button"

android:layout_gravity="right"

android:id="@+id/next_button" />

LinearLayout> 

LinearLayout>

Layout height is 

dp 

Density-independent-pixel is a relative variable specification that is always used when the app is supposed to run on different screen sizes with different resolutions. The dp unit is based on a screen resolution of 160 dpi. This means that 1 dp = 1 px (pixel) on a device with 160 dpi. 

On a screen with 240 dpi, 1 dp = 1.5 px. The conversion formula is: px = dp * (dpi /160)

 

Now your design should look like the Figure 1. 

Page 8 of 17


Step 2: Assigning functions to buttons

 

Both buttons, namely Correct and Wrong, should respond on clicking and display suitable text on screen depending on whether the answer was correct or wrong. This means that we must establish a contact between button definition in the layout file and the activity (MainActivity.java) which can respond to the user actions and executes one of the actions predefined by us. 

Life cycle

 

The life cycle of the app desired by us presently looks as follows: 

Starting the app 

MainActivity -> activity_main.xml 

A button is clicked -> MainActivity -> Display Message 

How can MainActivity respond to the button click? 

Resources such as images and text are stored in a R.java file. An activity retrieves information about a resource from the R.java file using the ID. In activity_main.xml file, you can see id for all buttons and textview. 

<Button

 

android:layout_width="wrap_content"

 

android:layout_height="wrap_content"

 

android:text="@string/true_button"

 

android:id="@+id/true_button" /> 

If you want to access a resource from an activity, you must first allocate an ID to it. From the activity, the “Correct button” resource accessed as following: 

findViewByID(R.id.true_button) 

Edit the MainActivity.java file

 

Until now, the MainActivity.java contains the code that was automatically generated when creating the project.

 package com.example.sunam.dinoquiz; 

import android.os.Bundle; 

import android.support.v7.app.ActionBarActivity; 

import android.view.Menu; 

import android.view.MenuItem;

Activities

 

An activity is the elementary component of an application that offers an interaction option to the user. You can create or import an interface in an activity using setContentView; the interface normally occupies the entire screen or is embedded in another activity. Various events might occur in the life cycle of an activity and change the activity state e.g. a tap on the Home button or an incoming call can push an activity in the foregrou



 DOWNLOAD SAMPLE ANSWER

Details

  • Number of views:
    389
  • PRICE :
    AU$ 220.00
Security Code  
Urgent Assignment Help

Our Top Experts


Karen Betty

Holding a PhD degree in Finance, Dr. John Adams is experienced in assisting students who are in dire need...

55 - Completed Orders


Daphne Lip

Canada, Toronto I have acquired my degree from Campion College at the University of Regina Occuption/Desi...

52 - Completed Orders


Mr Roberto Tuzii

Even since I was a student in Italy I had a passion for languages, in fact I love teaching Italian, and I...

102 - Completed Orders


Harsh Gupta

To work with an organization where I can optimally utilize my knowledge and skills for meeting challenges...

109 - Completed Orders


ARNAB BANERJEE

JOB OBJECTIVE Seeking entry level assignments in Marketing & Business Development with an organization...

202 - Completed Orders


KARAN BHANDARI

Current work profile Project manager- The Researchers Hub (2nd Jan 2016 to presently working) Researc...

20 - Completed Orders


Tan Kumar Ali

Sales Assistant, Mito Marina Assigned to the Stationery dept – assisted in merchandising, stock taking...

100 - Completed Orders


Wesenu Irko

Personal Profile Dedicated and highly experienced private chauffeur. High energy, hardworking, punctua...

200 - Completed Orders


Lizzy Darley

I'm Lizzy, full time education specialist in English, Essay Writing, Economics and Maths. Having Assi...

109 - Completed Orders


CRYSTAL

HSC PREPARATION I specialise in English coaching programs for HSC students. My personalised and results-...

202 - Completed Orders