Meniu. Create a project:
|
|
- Marsha Golden
- 6 years ago
- Views:
Transcription
1 Meniu Create a project: Project name: P0131_MenuSimple Build Target: Android Application name: MenuSimple Package name: ru.startandroid.develop.menusimple Create Activity: MainActivity Open MainActivity.java. oncreateoptionsmenu method is responsible for creating a menu. Menu object is passed to this method as a parameter. We will add our menu items into this object. The adding procedure is simple, add method is used. This method takes the text of the menu item as a parameter. Let s add 4 items public boolean oncreateoptionsmenu(menu menu) { menu.add("menu1"); menu.add("menu2"); menu.add("menu3"); menu.add("menu4"); return super.oncreateoptionsmenu(menu); oncreateoptionsmenu method returns a boolean result. True - show menu, False - do not show. So we could have made a checking of some condition, and as a result of this check do not show a menu returning False. We don t need this for now, so we delegate this choice to the method of superclass, it returns True by default. Save everything, run the application and click the emulator menu button. Four menu items appeared. Clicking them will do nothing as listener is not implemented. Activity is a listener and method is called onoptionsitemselected. It receives menu item which has been clicked as a parameter - MenuItem. It is possible to define which menu item has been clicked by gettitle method. Let s show a Toast message with the text of the menu item clicked. Method must return a boolean value at the end. And we delegate it to the superclass again:
2 public boolean onoptionsitemselected(menuitem item) { Toast.makeText(this, item.gettitle(), Toast.LENGTH_SHORT).show(); return super.onoptionsitemselected(item); Complete code: public class MainActivity extends Activity { /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public boolean oncreateoptionsmenu(menu menu) { menu.add("menu1"); menu.add("menu2"); menu.add("menu3"); menu.add("menu4"); return super.oncreateoptionsmenu(menu); public boolean onoptionsitemselected(menuitem item) { Toast.makeText(this, item.gettitle(), Toast.LENGTH_SHORT).show(); return super.onoptionsitemselected(item);
3 In the previous lesson we observed the simplest way of creating a menu using add(charsequence title) method, we passed only text as a parameter. Let s have a look at another implementation of this method - add(int groupid, int itemid, int order, CharSequence title). This methods takes 4 parameters: groupid - group identifier to which a menu item belongs to itemid - menu item ID order - for specifying the order in which menu items will be shown title - text that will be displayed We will create an application to illustrate how all these parameters are used. There will be a TextView and a CheckBox on the screen: - TextView will display which menu item was chosen - CheckBox will define whether to show a simple or expanded menu. It will be implemented using menu groups. Let me clarify that terms "simple menu" and "expanded menu" - are not Android terms, these are my namings. So when the application is running and the user clicks menu button, he will see a "simple" menu. If the user checks the CheckBox, the "expanded" menu which contains more items will be displayed. Let s create a project: Project name: P0141_MenuAdv Build Target: Android Application name: MenuAdv Package name: ru.startandroid.develop.menuadv Create Activity: MainActivity Open main.xml, assign the ID to an existing TextView, erase text in it and create a CheckBox. Code: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/chbextmenu" android:text="expanded menu"> </CheckBox> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/textview"> </TextView> </LinearLayout> Open MainActivity.java and fill in MainActivity class with the following code:
4 public class MainActivity extends Activity { // Screen elements TextView tv; CheckBox chb; /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); // find the elements tv = (TextView) findviewbyid(r.id.textview); chb = (CheckBox) findviewbyid(r.id.chbextmenu); // menu creation public boolean oncreateoptionsmenu(menu menu) { // adding menu items menu.add(0, 1, 0, "add"); menu.add(0, 2, 0, "edit"); menu.add(0, 3, 3, "delete"); menu.add(1, 4, 1, "copy"); menu.add(1, 5, 2, "paste"); menu.add(1, 6, 4, "exit"); return super.oncreateoptionsmenu(menu); // menu update public boolean onprepareoptionsmenu(menu menu) { // menu items with group ID = 1 are visible if CheckBox is checked menu.setgroupvisible(1, chb.ischecked()); return super.onprepareoptionsmenu(menu); // process clicks public boolean onoptionsitemselected(menuitem item) { StringBuilder sb = new StringBuilder(); // print the info about pressed menu item sb.append("item Menu"); sb.append("\r\n groupid: " + String.valueOf(item.getGroupId()));
5 sb.append("\r\n itemid: " + String.valueOf(item.getItemId())); sb.append("\r\n order: " + String.valueOf(item.getOrder())); sb.append("\r\n title: " + item.gettitle()); tv.settext(sb.tostring()); return super.onoptionsitemselected(item); Don t forget to update imports (CTRL + SHIFT +O). Let s look through the code above. We use the following methods: oncreateoptionsmenu - is invoked only when the menu is shown for the first time. Creates a menu and is not used any more. We add menu items here. onprepareoptionsmenu - invoked every time before displaying the menu. We make changes to the already existing menu if it is necessary. onoptionsitemselected - is invoked when the menu item is clicked. Here we define which menu item has been clicked. In the oncreateoptionsmenu we add 6 menu items. Have a look at the add method parameters. The first parameter is the group ID. For the first three items it equals 0, for the other three it equals 1. So the copy, paste and exit menu items are united into a group with ID = 1. Visually, it is not displayed in any way - they do not differ in color or something else. We will use group ID in onprepareoptionsmenu implementation. The second parameter is ID of menu item. It is used in listener to define which menu item has been pressed. We will use it in onoptionsitemselected. The third parameter defines the item position in the menu. This parameter is used for defining the order of menu items when it is displayed. The sort order is ascending, from smaller order to larger. The fourth parameter is text, which will be displayed on the menu item. Everything is clear with it. Menu object is passed to onprepareoptionsmenu method and we can work with it. In the current example we invoke setgroupvisible. This method allows to hide\show menu items. It is passed two parameters - group ID and a boolean value. We write 1 for the group ID (the same group which contains copy, paste and exit menu items). We will use thecheckbox state as a boolean parameter. If it is checked, menu items (from the group where ID = 1) will be displayed, if not - items will not be displayed. Let s save everything and launch the application. "Simple" menu:
6 "Expanded" menu
7 Depending on CheckBox state, 3 or 6 items in menu are visible. Pay attention to the item order. They are sorted by order parameter ascending. If the order of several items is the same, these items will be positioned in the order of their creation in oncreateoptionsmenu method. When pressing any menu item, onoptionsitemselected method is triggered. In this method we output the information about the item pressed to the TextView. You can compare this information to those we have coded when creating menu items. All the parameters have to match. I ve made the same order of items as in the add method for convenience: groupid, itemid, order, title. Try to add some more items to the menu and have a look how they are displayed. To simplify the code I ve hardcoded numbers for group IDs and menu item IDs. Usually, it is recommended to use constants. I will use constants further. XML-menu There is one more convenient and preferable way of creating a menu - using an xml-file, the same as layout-file when creating a screen. To get a menu which we have created programmatically in this lesson, we will create mymenu.xml file in res/menu folder: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android=" <item
8 android:title="add"> </item> <item android:title="edit"> </item> <item android:orderincategory="3" android:title="delete"> </item> <group <item android:orderincategory="1" android:title="copy"> </item> <item android:orderincategory="2" android:title="paste"> </item> <item android:orderincategory="4" android:title="exit"> </item> </group> </menu> item - is a menu item, group - group of items. In the ID attributes we use the same approach as with IDs of screen components and Eclipse will generate these IDs in R.java. orderincategory attribute is the order of items, title is a text of menu item. Now we don t need to hardcode the creation of each menu item, we will just connect menu, which is passed as a parameter to the oncreateoptionsmenu method and our xml-file: public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.mymenu, menu); return super.oncreateoptionsmenu(menu); Using getmenuinflater method we obtain MenuInflater and invoke its inflate method. We pass our mymenu.xml file from res/menu folder and menu object as parameters. MenuInflater takes a menu object and fills it with menu items from mymenu.xml file. if you want to hide a group, invoke the same setgroupvisible method and pass R.id.group1 as a parameter for group ID. You can view attributes for menu xml-file in more details here. I recommend you to try and test both ways of creating a menu. Creating menu programmatically is more flexible, but xml shrinks the code amount.
9 Context menu in Android is invoked by long pressing any screen component. It is usually used in lists. When the list of similar objects is displayed (like messages in the mailbox) and you need to apply an action to one of these objects, a context menu is invoked for this object. But we didn t study lists yet, so we will make a simpler example and will invoke a context menu for TextView. Let s create a project: Project name: P0151_ContextMenu Build Target: Android Application name: ContextMenu Package name: ru.startandroid.develop.contextmenu Create Activity: MainActivity Open main.xml and create two TextView objects there: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_height="wrap_content" android:textsize="26sp" android:layout_width="wrap_content" android:id="@+id/tvcolor" android:layout_marginbottom="50dp" android:layout_margintop="50dp" android:text="text color"> </TextView> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textsize="22sp" android:id="@+id/tvsize" android:text="text size"> </TextView> </LinearLayout> For the first TextView we will make a context menu using which we will change the text color. For the second we will change the text size. The way of creating a context menu is quite similar to creating a simple menu. But there are some differences. oncreatecontextmenu method is invoked every time before the menu is displayed. It is passed these parameters: - ContextMenu, into which we will add items - View - screen element, which the context menu is invoked for - ContextMenu.ContextMenuInfo - contains additional information, when the context menu is invoked for a list element. We don t use it for now, but when we will learn lists, we will see that it is useful.
10 oncontextitemselected process method is similar to onoptionsitemselected for a simple menu. MenuItem is passed as a parameter - it is a menu item that has been clicked. We will also need a third method registerforcontextmenu. It is passed View as a parameter and it means that context menu should be created for this View. If you do not invoke this method, context menu for a View will not be created. Lets code. Open MainActivity.java. Let s declare and find TextView and point out that context menu must be created for them. TextView tvcolor, tvsize; /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); tvcolor = (TextView) findviewbyid(r.id.tvcolor); tvsize = (TextView) findviewbyid(r.id.tvsize); // context menu should be created for tvcolor and tvsize registerforcontextmenu(tvcolor); registerforcontextmenu(tvsize); Now let s code the creation of context menus. We will use constants for storing menu item IDs. final int MENU_COLOR_RED = 1; final int MENU_COLOR_GREEN = 2; final int MENU_COLOR_BLUE = 3; final int MENU_SIZE_22 = 4; final int MENU_SIZE_26 = 5; final int MENU_SIZE_30 = 6; And create public void oncreatecontextmenu(contextmenu menu, View v, ContextMenuInfo menuinfo) { switch (v.getid()) { case R.id.tvColor: menu.add(0, MENU_COLOR_RED, 0, "Red"); menu.add(0, MENU_COLOR_GREEN, 0, "Green"); menu.add(0, MENU_COLOR_BLUE, 0, "Blue"); case R.id.tvSize:
11 menu.add(0, MENU_SIZE_22, 0, "22"); menu.add(0, MENU_SIZE_26, 0, "26"); menu.add(0, MENU_SIZE_30, 0, "30"); Pay attention that we define View for which context menu was invoked by its ID and depending on this ID, create a specific menu. So if context menu was invoked for tvcolor, we create a menu with colors enumeration, if for tvsize - enumeration with font sizes. We use constants as item IDs. We don t apply grouping or sorting, that s why we use zeros as corresponding parameters. Now you can save everything and run. When long pressing a TextView context menu should appear. But clicking on items does nothing as we haven t written processing in oncontextitemselected method. Let s fill it in: public boolean oncontextitemselected(menuitem item) { switch (item.getitemid()) { // menu items for tvcolor case MENU_COLOR_RED: tvcolor.settextcolor(color.red);
12 tvcolor.settext("text color = red"); case MENU_COLOR_GREEN: tvcolor.settextcolor(color.green); tvcolor.settext("text color = green"); case MENU_COLOR_BLUE: tvcolor.settextcolor(color.blue); tvcolor.settext("text color = blue"); // menu items for tvsize case MENU_SIZE_22: tvsize.settextsize(22); tvsize.settext("text size = 22"); case MENU_SIZE_26: tvsize.settextsize(26); tvsize.settext("text size = 26"); case MENU_SIZE_30: tvsize.settextsize(30); tvsize.settext("text size = 30"); return super.oncontextitemselected(item); In this method we define by ID which menu item has been clicked. And we do the corresponding actions afterwards: change the text color for tvcolor and font size for tvsize. Save, run and see that context menus now react to clicks and do what is required from them To broaden your horizons I would like to write something else about this topic. It may seem complicated for now, but it it s fine. So here are some thoughts. We have used registerforcontextmenu(view view) method for turning on context menu for a specific View. This method belongs to Activity class. I ve looked at the source code of this method. The following is written there: public void registerforcontextmenu(view view) { view.setoncreatecontextmenulistener(this); Remember our lesson (9) about listeners and have a look at help for setoncreatecontextmenulistener (View.OnCreateContextMenuListener l) method. It looks like View uses thisobject as listener for creating context menu. In this case, our code is inside Activity, so it means that this object is Activity. It means when a View wants to show a context menu, it refers to listener (Activity) and it invokes its oncreatecontextmenu method. So it is the similar concept as with a simple click.
13 And a line in MainActivity.java: registerforcontextmenu(tvcolor); is absolutely equal to this line: tvcolor.setoncreatecontextmenulistener(this); We can also create our own object that implements View.OnCreateContextMenuListener and use it instead of Activity as a listener for creating a context menu. Don t forget that you can also use XML-method to create a context menu, which we have reviewed at the end of the previous lesson. Try to complete the same lesson again, but using XML-menu this time. Complete lesson code: public class MainActivity extends Activity { final int MENU_COLOR_RED = 1; final int MENU_COLOR_GREEN = 2; final int MENU_COLOR_BLUE = 3; final int MENU_SIZE_22 = 4; final int MENU_SIZE_26 = 5; final int MENU_SIZE_30 = 6; TextView tvcolor, tvsize; /** Called when the activity is first created. */ public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); tvcolor = (TextView) findviewbyid(r.id.tvcolor); tvsize = (TextView) findviewbyid(r.id.tvsize); // context menu should be created for tvcolor and tvsize registerforcontextmenu(tvcolor); registerforcontextmenu(tvsize); public void oncreatecontextmenu(contextmenu menu, View v, ContextMenuInfo menuinfo) {
14 switch (v.getid()) { case R.id.tvColor: menu.add(0, MENU_COLOR_RED, 0, "Red"); menu.add(0, MENU_COLOR_GREEN, 0, "Green"); menu.add(0, MENU_COLOR_BLUE, 0, "Blue"); case R.id.tvSize: menu.add(0, MENU_SIZE_22, 0, "22"); menu.add(0, MENU_SIZE_26, 0, "26"); menu.add(0, MENU_SIZE_30, 0, "30"); public boolean oncontextitemselected(menuitem item) { switch (item.getitemid()) { // menu items for tvcolor case MENU_COLOR_RED: tvcolor.settextcolor(color.red); tvcolor.settext("text color = red"); case MENU_COLOR_GREEN: tvcolor.settextcolor(color.green); tvcolor.settext("text color = green"); case MENU_COLOR_BLUE: tvcolor.settextcolor(color.blue); tvcolor.settext("text color = blue"); // menu items for tvsize case MENU_SIZE_22: tvsize.settextsize(22); tvsize.settext("text size = 22"); case MENU_SIZE_26: tvsize.settextsize(26); tvsize.settext("text size = 26"); case MENU_SIZE_30: tvsize.settextsize(30); tvsize.settext("text size = 30"); return super.oncontextitemselected(item);
Android Programs Day 5
Android Programs Day 5 //Android Program to demonstrate the working of Options Menu. 1. Create a New Project. 2. Write the necessary codes in the MainActivity.java to create OptionMenu. 3. Add the oncreateoptionsmenu()
More informationAndroid Using Menus. Victor Matos Cleveland State University
Lesson 8 Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright 2008-2009 CommonsWare, LLC. ISBN: 978-0-9816780-0-9 & Android Developers http://developer.android.com/index.html
More informationAndroid Using Menus. Victor Matos Cleveland State University
8 Android Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright 2008-2009 CommonsWare, LLC. ISBN: 978-0-9816780-0-9 & Android Developers http://developer.android.com/index.html
More informationAction Bar. (c) 2010 Haim Michael. All Rights Reserv ed.
Action Bar Introduction The Action Bar is a widget that is shown on top of the screen. It includes the application logo on its left side together with items available from the options menu on the right.
More informationAndroid Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop
Workshop 1. Create an Option Menu, and convert it into Action Bar (Page 1 8) Create an simple Option Menu Convert Option Menu into Action Bar Create Event Listener for Menu and Action Bar Add System Icon
More informationVienos veiklos būsena. Theory
Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is
More informationandroid:orientation="horizontal" android:layout_margintop="30dp"> <Button android:text="button2"
Parametrų keitimas veikiančioje aplikacijoje Let s create a project: Project name: P0181_DynamicLayout3 Build Target: Android 2.3.3 Application name: DynamicLayout3 Package name: ru.startandroid.develop.dynamiclayout3
More informationAndroid Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9)
Android Specifics Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9) Android Specifics ArrayAdapter Preferences Widgets Jonathan Diehl, Hendrik Thüs 2 ArrayAdapter Jonathan Diehl, Hendrik Thüs
More informationMobila applikationer och trådlösa nät, HI1033, HT2013
Mobila applikationer och trådlösa nät, HI1033, HT2013 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android
More informationIntroducing the Android Menu System
Introducing the Android Menu System If you ve ever tried to navigate a mobile phone menu system using a stylus or trackball, you ll know that traditional menu systems are awkward to use on mobile devices.
More informationHave a development environment in 256 or 255 Be familiar with the application lifecycle
Upcoming Assignments Readings: Chapter 4 by today Horizontal Prototype due Friday, January 22 Quiz 2 today at 2:40pm Lab Quiz next Friday during lecture time (2:10-3pm) Have a development environment in
More informationAndroid Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.
Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Framework Support (e.g. Android) 2 Framework Capabilities
More informationQ.1 Explain the dialog and also explain the Demonstrate working dialog in android.
Q.1 Explain the dialog and also explain the Demonstrate working dialog in android. - A dialog is a small window that prompts the user to make a decision or enter additional information. - A dialog does
More informationMobila applikationer och trådlösa nät, HI1033, HT2012
Mobila applikationer och trådlösa nät, HI1033, HT2012 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android
More informationPreferences. Marco Ronchetti Università degli Studi di Trento
1 Preferences Marco Ronchetti Università degli Studi di Trento SharedPreferences SharedPreferences allows to save and retrieve persistent key-value pairs of primitive data types. This data will persist
More informationMobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.
Simple Android Application for Native Calculator Aim: To develop a Simple Android Application for Native Calculator. Procedure: Creating a New project: Open Android Stdio and then click on File -> New
More informationAndroid Application Model I
Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath Reading: Big Nerd Ranch Guide, Chapters 3, 5 (Activities);
More informationMobile Programming Lecture 7. Dialogs, Menus, and SharedPreferences
Mobile Programming Lecture 7 Dialogs, Menus, and SharedPreferences Agenda Dialogs Menus SharedPreferences Android Application Components 1. Activity 2. Broadcast Receiver 3. Content Provider 4. Service
More informationAndroid Apps Development for Mobile and Tablet Device (Level I) Lesson 2
Workshop 1. Compare different layout by using Change Layout button (Page 1 5) Relative Layout Linear Layout (Horizontal) Linear Layout (Vertical) Frame Layout 2. Revision on basic programming skill - control
More information05. RecyclerView and Styles
05. RecyclerView and Styles 08.03.2018 1 Agenda Intents Creating Lists with RecyclerView Creating Cards with CardView Application Bar Menu Styles and Themes 2 Intents 3 What is Intent? An Intent is an
More informationAccelerating Information Technology Innovation
Accelerating Information Technology Innovation http://aiti.mit.edu India Summer 2012 Review Session Android and Web Working with Views Working with Views Create a new Android project. The app name should
More information07. Menu and Dialog Box. DKU-MUST Mobile ICT Education Center
07. Menu and Dialog Box DKU-MUST Mobile ICT Education Center Goal Learn how to create and use the Menu. Learn how to use Toast. Learn how to use the dialog box. Page 2 1. Menu Menu Overview Menu provides
More information1. Simple List. 1.1 Simple List using simple_list_item_1
1. Simple List 1.1 Simple List using simple_list_item_1 1. Create the Android application with the following attributes. Application Name: MySimpleList Project Name: Package Name: MySimpleList com.example.mysimplelist
More informationAction Bar. Action bar: Top navigation bar at each screen The action bar is split into four different functional areas that apply to most apps.
1 Action Bar Action bar: Top navigation bar at each screen The action bar is split into four different functional areas that apply to most apps. 1) App Icon 3) Action Buttons 2)View Control 4) Action Overflows
More informationEMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation
EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Managing Screen Orientation ORIENTATIONS Portrait Landscape Reverse portrait Reverse landscape ON REVERSE PORTRAIT Android: all four orientations are
More informationCreate Parent Activity and pass its information to Child Activity using Intents.
Create Parent Activity and pass its information to Child Activity using Intents. /* MainActivity.java */ package com.example.first; import android.os.bundle; import android.app.activity; import android.view.menu;
More informationAndroid App Development. Mr. Michaud ICE Programs Georgia Institute of Technology
Android App Development Mr. Michaud ICE Programs Georgia Institute of Technology Android Operating System Created by Android, Inc. Bought by Google in 2005. First Android Device released in 2008 Based
More informationCSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015
CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 Comment and Evaluation: This lab introduces us about Android SDK and how to write a program for Android platform. The calculator is pretty easy, everything
More informationPractical 1.ListView example
Practical 1.ListView example In this example, we show you how to display a list of fruit name via ListView. Android Layout file File : res/layout/list_fruit.xml
More informationManaging Data. However, we'll be looking at two other forms of persistence today: (shared) preferences, and databases.
Managing Data This week, we'll be looking at managing information. There are actually many ways to store information for later retrieval. In fact, feel free to take a look at the Android Developer pages:
More informationEmbedded Systems Programming - PA8001
Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 9 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering
More informationIntents. Your first app assignment
Intents Your first app assignment We will make this. Decidedly lackluster. Java Code Java Code XML XML Preview XML Java Code Java Code XML Buttons that work
More informationApp Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out
App Development for Smart Devices CS 495/595 - Fall 2013 Lec #7: Audio, Video & Telephony Try It Out Tamer Nadeem Dept. of Computer Science Trt It Out Example - SoundPool Example - VideoView Page 2 Fall
More informationArrays of Buttons. Inside Android
Arrays of Buttons Inside Android The Complete Code Listing. Be careful about cutting and pasting.
More informationSouth Africa Version Control.
South Africa 2013 Lecture 7: User Interface (Navigation)+ Version Control http://aiti.mit.edu South Africa 2013 Today s agenda Recap Navigation Version Control 2 Tutorial Recap Activity 1 Activity 2 Text
More informationThread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.
1 Thread A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables. Each virtual machine instance has at least one main
More informationProduced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar
Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology
More informationOur First Android Application
Mobile Application Development Lecture 04 Imran Ihsan Our First Android Application Even though the HelloWorld program is trivial in introduces a wealth of new ideas the framework, activities, manifest,
More informationEMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State
EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Saving State THE PROBLEM How to save the state (of a UI, for instance) so that it survives even when the application is closed/killed The state should
More informationAndroid HelloWorld - Example. Tushar B. Kute,
Android HelloWorld - Example Tushar B. Kute, http://tusharkute.com Anatomy of Android Application Anatomy of Android Application Java This contains the.java source files for your project. By default, it
More informationProduced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar
Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology
More informationNotification mechanism
Notification mechanism Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University. Portions of this page are reproduced from work created
More informationELET4133: Embedded Systems. Topic 15 Sensors
ELET4133: Embedded Systems Topic 15 Sensors Agenda What is a sensor? Different types of sensors Detecting sensors Example application of the accelerometer 2 What is a sensor? Piece of hardware that collects
More informationBasic GUI elements - exercises
Basic GUI elements - exercises https://developer.android.com/studio/index.html LIVE DEMO Please create a simple application, which will be used to calculate the area of basic geometric figures. To add
More informationMobile and Ubiquitous Computing: Android Programming (part 3)
Mobile and Ubiquitous Computing: Android Programming (part 3) Master studies, Winter 2015/2016 Dr Veljko Pejović Veljko.Pejovic@fri.uni-lj.si Based on Programming Handheld Systems, Adam Porter, University
More informationCOMP4521 EMBEDDED SYSTEMS SOFTWARE
COMP4521 EMBEDDED SYSTEMS SOFTWARE LAB 1: DEVELOPING SIMPLE APPLICATIONS FOR ANDROID INTRODUCTION Android is a mobile platform/os that uses a modified version of the Linux kernel. It was initially developed
More informationProgramming with Android: Animations, Menu, Toast and Dialogs. Luca Bedogni. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna
Programming with Android: Animations, Menu, Toast and Dialogs Luca Bedogni Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna Animations vmake the components move/shrink/color vmainly
More informationFigure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.
44 CHAPTER 2 Android s development environment Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard. TIP You ll want the package name of your applications to be unique
More informationStarting Another Activity Preferences
Starting Another Activity Preferences Android Application Development Training Xorsat Pvt. Ltd www.xorsat.net fb.com/xorsat.education Outline Starting Another Activity Respond to the Button Create the
More informationAndroid Workshop: Model View Controller ( MVC):
Android Workshop: Android Details: Android is framework that provides java programmers the ability to control different aspects of smart devices. This interaction happens through the Android SDK (Software
More informationLet s take a display of HTC Desire smartphone as an example. Screen size = 3.7 inches, resolution = 800x480 pixels.
Screens To begin with, here is some theory about screens. A screen has such physical properties as size and resolution. Screen size - a distance between two opposite corners of the screens, usually measured
More informationAndroid Beginners Workshop
Android Beginners Workshop at the M O B IL E M O N D AY m 2 d 2 D E V E L O P E R D A Y February, 23 th 2010 Sven Woltmann, AndroidPIT Sven Woltmann Studied Computer Science at the TU Ilmenau, 1994-1999
More information8/30/15 MOBILE COMPUTING. CSE 40814/60814 Fall How many of you. have implemented a command-line user interface?
MOBILE COMPUTING CSE 40814/60814 Fall 2015 How many of you have implemented a command-line user interface? 1 How many of you have implemented a graphical user interface? HTML/CSS Java Swing.NET Framework
More information<uses-permission android:name="android.permission.internet"/>
Chapter 11 Playing Video 11.1 Introduction We have discussed how to play audio in Chapter 9 using the class MediaPlayer. This class can also play video clips. In fact, the Android multimedia framework
More information1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation
1. Location Services 1.1 GPS Location 1. Create the Android application with the following attributes. Application Name: MyLocation Project Name: Package Name: MyLocation com.example.mylocation 2. Put
More informationInterface ใน View class ประกอบด วย
Boonrit kidngan Interface ใน View class ประกอบด วย View.OnClickListener เม อม การ click View.OnLongClickListener เม อม การ click ค าง View.OnFocusChangeListener เม อเปล ยนการเล อก View.OnKeyListener เม
More informationActionBar. import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { }
Android ActionBar import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { Layout, activity.xml
More informationSolving an Android Threading Problem
Home Java News Brief Archive OCI Educational Services Solving an Android Threading Problem Introduction by Eric M. Burke, Principal Software Engineer Object Computing, Inc. (OCI) By now, you probably know
More informationCS 4330/5390: Mobile Application Development Exam 1
1 Spring 2017 (Thursday, March 9) Name: CS 4330/5390: Mobile Application Development Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and closed-book.
More informationLecture 14. Android Application Development
Lecture 14 Android Application Development Notification Instructor Muhammad Owais muhammad.owais@riphah.edu.pk Cell: 03215500223 Notifications Used to notify user for events Three general forms of Notifications
More informationEMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches
EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI Specification: Approaches UIS: APPROACHES Programmatic approach: UI elements are created inside the application code Declarative approach: UI elements are listed
More informationDatabase Development In Android Applications
ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Database Development In Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran
More informationPreferences. Marco Ronchetti Università degli Studi di Trento
1 Preferences Marco Ronchetti Università degli Studi di Trento SharedPreferences SharedPreferences allows to save and retrieve persistent key-value pairs of primitive data types. This data will persist
More informationUser Interface Design & Development
User Interface Design & Development Lecture Intro to Android João Pedro Sousa SWE 632, Fall 2011 George Mason University features multitasking w/ just-in-time compiler for Dalvik-VM bytecode storage on
More informationApp Development for Smart Devices. Lec #2: Activities, Intents, and User Interface
App Development for Smart Devices CS 495/595 - Fall 2012 Lec #2: Activities, Intents, and User Interface Tamer Nadeem Dept. of Computer Science Content Review Android Activities Android Intents User Interface
More informationAndroid Data Storage
Lesson 14 Android Persistency: Victor Matos Cleveland State University Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright 2008-2009 CommonsWare, LLC. ISBN: 978-0-9816780-0-9
More informationAndroid Navigation Drawer for Sliding Menu / Sidebar
Android Navigation Drawer for Sliding Menu / Sidebar by Kapil - Tuesday, December 15, 2015 http://www.androidtutorialpoint.com/material-design/android-navigation-drawer-for-sliding-menusidebar/ YouTube
More informationPENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)
PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) Network Connection Web Service K Candra Brata andra.course@gmail.com Mobille App Lab 2015-2016 Network Connection http://developer.android.com/training/basics/network-ops/connecting.html
More informationMobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling
Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling Lecture 1 Review How to edit XML files in Android Studio? What holds all elements (Views) that appear to the user in an Activity?
More informationUI, Continued. CS 2046 Mobile Application Development Fall Jeff Davidson CS 2046
UI, Continued CS 2046 Mobile Application Development Fall 2010 Announcements Office hours have started HW1 is out, due Monday, 11/1, at 11:59 pm Clarifications on HW1: To move where the text appears in
More informationandroid-espresso #androidespresso
android-espresso #androidespresso Table of Contents About 1 Chapter 1: Getting started with android-espresso 2 Remarks 2 Examples 2 Espresso setup instructions 2 Checking an Options Menu items (using Spoon
More informationITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences
ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Shared Preferences 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran Tanveer, ITU Experts
More informationData Persistence. Chapter 10
Chapter 10 Data Persistence When applications create or capture data from user inputs, those data will only be available during the lifetime of the application. You only have access to that data as long
More informationTextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input
1 UI Components 2 UI Components 3 A label is called a TextView. TextView TextViews are typically used to display a caption TextViews are not editable, therefore they take no input - - - - - - -
More informationProgramming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna
Programming with Android: Introduction Layouts Luca Bedogni Marco Di Felice Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna Views: outline Main difference between a Drawable and
More informationIPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application.
Learning Unit Exam Project IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application. The delivery of this project is essential
More informationMAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.
MAD ASSIGNMENT NO 2 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. Android Widgets There are given a lot of android widgets with simplified
More informationManifest.xml. Activity.java
Dr.K.Somasundaram Ph.D Professor Department of Computer Science and Applications Gandhigram Rural Institute, Gandhigram, Tamil Nadu-624302, India ka.somasundaram@gmail.com Manifest.xml
More informationEMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs
EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Tip: Switching UIs THE PROBLEM How to switch from one UI to another Each UI is associated with a distinct class that controls it Solution shown: two UIs,
More informationTabel mysql. Kode di PHP. Config.php. Service.php
Tabel mysql Kode di PHP Config.php Service.php Layout Kode di Main Activity package com.example.mini.webandroid; import android.app.progressdialog; import android.os.asynctask; import android.support.v7.app.appcompatactivity;
More informationANDROID USER INTERFACE
1 ANDROID USER INTERFACE Views FUNDAMENTAL UI DESIGN Visual interface element (controls or widgets) ViewGroup Contains multiple widgets. Layouts inherit the ViewGroup class Activities Screen being displayed
More informationGetting Started With Android Feature Flags
Guide Getting Started With Android Feature Flags INTRO When it comes to getting started with feature flags (Android feature flags or just in general), you have to understand that there are degrees of feature
More informationAndroid Application Development. By : Shibaji Debnath
Android Application Development By : Shibaji Debnath About Me I have over 10 years experience in IT Industry. I have started my career as Java Software Developer. I worked in various multinational company.
More informationOverview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners
Layouts and Views http://developer.android.com/guide/topics/ui/declaring-layout.html http://developer.android.com/reference/android/view/view.html Repo: https://github.com/karlmorris/viewsandlayouts Overview
More informationApp Development for Smart Devices. Lec #18: Advanced Topics
App Development for Smart Devices CS 495/595 - Fall 2011 Lec #18: Advanced Topics Tamer Nadeem Dept. of Computer Science Objective Web Browsing Android Animation Android Backup Presentation - Developing
More informationAndroid: Intents, Menus, Reflection, and ListViews
,,, and,,, and Harvard University March 1, 2011 Announcements,,, and Lecture videos available at: https://www.cs76.net/lectures Section schedule: https://www.cs76.net/sections n-puzzle walkthrough: https://www.cs76.net/sections
More informationEmbedded Systems Programming - PA8001
Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 8 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering
More informationProduced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar
Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology
More informationSimple Currency Converter
Simple Currency Converter Implementing a simple currency converter: USD Euro Colon (CR) Note. Naive implementation using the rates 1 Costa Rican Colon = 0.001736 U.S. dollars 1 Euro = 1.39900 U.S. dollars
More information5Displaying Pictures and Menus with Views
5Displaying Pictures and Menus with Views WHAT YOU WILL LEARN IN THIS CHAPTER How to use the Gallery, ImageSwitcher, GridView, and ImageView views to display images How to display options menus and context
More informationMultiple devices. Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers
Multiple devices Multiple devices Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers Create a new directory in your project's res/ and name it using the
More informationDistributed Systems HS2010 Android live hacking
Page 1 of 14 Distributed Systems HS2010 Android live hacking General hints Uninstall Application when switch to a different development PC Do not press Run with XML files Often no connection to debugger
More informationCreate new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.
Hello World Lab Objectives: Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.xml What to Turn in: The lab evaluation
More informationDeveloped and taught by well-known Contact author and developer. At public for details venues or onsite at your location.
2011 Marty Hall Android Programming Basics Originals of Slides and Source Code for Examples: http://www.coreservlets.com/android-tutorial/ Customized Java EE Training: http://courses.coreservlets.com/
More informationTopics of Discussion
Reference CPET 565 Mobile Computing Systems CPET/ITC 499 Mobile Computing Fragments, ActionBar and Menus Part 3 of 5 Android Programming Concepts, by Trish Cornez and Richard Cornez, pubslihed by Jones
More informationSoftware Practice 3 Before we start Today s lecture Today s Task Team organization
1 Software Practice 3 Before we start Today s lecture Today s Task Team organization Prof. Hwansoo Han T.A. Jeonghwan Park 43 2 Lecture Schedule Spring 2017 (Monday) This schedule can be changed M A R
More informationANDROID PROGRAMS DAY 3
ANDROID PROGRAMS DAY 3 //Android project to navigate from first page to second page using Intent Step 1: Create a new project Step 2: Enter necessary details while creating project. Step 3: Drag and drop
More informationUI (User Interface) overview Supporting Multiple Screens Touch events and listeners
http://www.android.com/ UI (User Interface) overview Supporting Multiple Screens Touch events and listeners User Interface Layout The Android user interface (UI) consists of screen views (one or more viewgroups
More informationDistributed Systems HS2011 Android live hacking
Page 1 of 14 Distributed Systems HS2011 Android live hacking General hints Uninstall Application when switching to a different development computer Often no connection to debugger on emulator restart emulator
More informationProduced by. Mobile Application Development. Eamonn de Leastar
Mobile Application Development Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie A First
More information