Android Programming - Features

Slides:



Advertisements
Similar presentations
CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Advertisements

User Interface Classes.  Design Principles  Views & Layouts  Event Handling  Menus  Dialogs.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Basic, Basic, Basic Android. What are Packages? Page 346 in text Package statement goes before any import statements Indicates that the class declared.
By: Jeremy Smith.  Introduction  Droid Draw  Add XML file  Layouts  LinearLayout  RelativeLayout  Objects  Notifications  Toast  Status Bar.
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
Android Development (Basics)
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
Chapter 2: Simplify! The Android User Interface
Mobile Programming Lecture 6
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
@2011 Mihail L. Sichitiu1 Android Introduction GUI Menu Many thanks to Jun Bum Lim for his help with this tutorial.
CE Applied Communications Technology Android lecture 2 - Structures Android File structure Resources Drawables Layout Values R Class Manifest Running.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
Android - Broadcast Receivers
Networking: Part 1 (Web Content). Networking with Android Android provides A full-featured web browser based on Chromium, the open source browser engine.
1 Introducing Activity and Intent. 2 Memory LinearLayout, weight=2 LinearLayout, weight=1 TextView ListView.
Webview and Web services. Web Apps You can make your web content available to users in two ways in a traditional web browser in an Android application,
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Android Using Menus Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC. ISBN:
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
ANDROID DIALOGS. Slide 2 Dialogs (Introduction) The Dialog class is the base class for all dialogs A dialog is a small window that prompts the user to.
Android Programming.
Chapter 2: Simplify! The Android User Interface
Lab7 – Appendix.
Google VR (gvr) CardBoard and DayDream With OpenGL
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
Android Application Development 1 6 May 2018
CS499 – Mobile Application Development
Android N Amanquah.
Adapting to Display Orientation
CS240: Advanced Programming Concepts
GUI Programming Fundamentals
Android – Event Handling
Android Introduction Hello World.
Android Notifications
Android Widgets 1 7 August 2018
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
ITEC535 – Mobile Programming
Politeknik Elektronika Negeri Surabaya
Android Introduction Camera.
תכנות ב android אליהו חלסצ'י.
Mobile Device Development
Android Introduction Hello Views Part 2.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Many thanks to Jun Bum Lim for his help with this tutorial.
CMPE419 Mobile Application Development
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
Activities and Intents
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android Notifications
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
Activities, Fragments, and Intents
Android Sensor Programming
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Android Programming - Features Lecture 4/5 Zablon Ochomo zochomo@icontrace.com

Android Programming Java Netbeans Android SDK www.nbandroid.org for instructions on how to setup android for Netbeans IDE SDK Manager AVD Manager Android Packages

Android Menus Menu types: Context menu: is the menu in context/associated with some object. Long-press on the view will bring up the registered Context menu. Option menu: menu opened when MENU key on the device is clicked. Icon menu contain 1st six options while expanded menu are available when More button is clicked Sub menus: is the nested menu that can be added to any type of menu (options or context menu)

Options menu example Refer to “siasa” app provided on the cource website. Check under resources/menu folder for “party_menu.xml” <?xml version="1.0" encoding="UTF-8"?><menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/official" android:icon="@drawable/odm_bullet" android:title="Official" /> <item android:id="@+id/stories" android:icon="@drawable/odm_bullet" android:title="Stories" /> <item android:id="@+id/community" android:icon="@drawable/odm_bullet" android:title="Community news" /> <item android:id="@+id/tv" android:icon="@drawable/odm_bullet" android:title="Orange TV" /> <item android:id="@+id/ittt" android:icon="@drawable/odm_bullet" android:title="About it and tt" /></menu>

Inflating the menu from XML @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.party_menu, menu); return true; } Add this code snippet on your Activity code.

Add event listener to your menu @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.official: mWebView.loadUrl("http://www.odm.co.ke"); return true; case R.id.community: case R.id.stories: case R.id.tv: case R.id.ittt: mWebView.loadUrl("http://www.icontrace.com"); default: return super.onOptionsItemSelected(item); }

Android Dialog A dialog is usually a small window that appears in front of the current Activity. The underlying Activity loses focus and the dialog accepts all user interaction. Dialogs are normally used for notifications that should interupt the user and to perform short tasks that directly relate to the application in progress (such as a progress bar or a login prompt). The Dialog class is the base class for creating dialogs. However, you typically should not instantiate a Dialog directly. Instead, you should use one of the following subclasses:

Android Dialog AlertDialog A dialog that can manage zero, one, two, or three buttons, and/or a list of selectable items that can include checkboxes or radio buttons. The AlertDialog is capable of constructing most dialog user interfaces and is the suggested dialog type. ProgressDialog A dialog that displays a progress wheel or progress bar. Because it's an extension of the AlertDialog, it also supports buttons. DatePickerDialog A dialog that allows the user to select a date. See the Hello DatePicker tutorial. TimePickerDialog A dialog that allows the user to select a time. If you would like to customize your own dialog, you can extend the base Dialog object or any of the subclasses listed above and define a new layout.

Web View WebView allows you to create your own window for viewing web pages (or even develop a complete browser). In this tutorial, you'll create a simple Activity that can view and navigate web pages.

Activity package com.siasakenya.android.siasa; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends Activity { WebView mWebView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.loadUrl("http://www.odm.co.ke"); mWebView.setWebViewClient(new ODMWebViewClient()); } public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.party_menu, menu); return true; public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.official: case R.id.community: case R.id.stories: case R.id.tv: case R.id.ittt: mWebView.loadUrl("http://www.icontrace.com"); default: return super.onOptionsItemSelected(item); private class ODMWebViewClient extends WebViewClient { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url);

Permission in the manifest file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.siasakenya.android.siasa" android:versionCode="1" android:versionName="1.0"> <application android:label="@string/app_name" android:icon="@drawable/odm1"> <activity android:name="MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.INTERNET" /> </manifest>

Layout for WebView Widget support <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/logoImage" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:src="@drawable/logo"/> <WebView android:id="@+id/webview" android:layout_height="fill_parent"/> </LinearLayout>

Lab project Check the siasa and Androworks netbeans project for web view List view, menus, menu actions and dialogs