当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

西安电子科技大学:《Mobile Programming》课程PPT教学课件(Android Programming)Lecture 04 Activity, Intent and UI

资源类别:文库,文档格式:PPTX,文档页数:81,文件大小:2.1MB,团购合买
点击下载完整版文档(PPTX)

Android Programming Lecture 4 Activity, Intent and U

Android Programming Lecture 4 Activity, Intent and UI

package com. example. editgreeting: import android app. Activity;l Superclass public class MainActivity extends Activity EditText e; TextView t: Button b protected void onCreate(Bundle savedInstancestate)t super onCreate (savedInstancestate) setContentView(R layout activity main); e =(EditTextfindviewById(rid. myEdit Text) (TextView)findviewById(r id my Textview) b = Button)findViewById(R id my Button), Constructor b. setonClickListener (new MyButtononClickListener() class My ButtonOnClickListener implements pnClickListene @Override Interface Inner class public void onclick(View v)i // TODO Auto-generated method stub t setText(e getText

2 Superclass Interface Constructor Inner class

RoadMap and Learning Objectives Learn to use the basic ul widgets Learn to switch Activities using Explicit Intent

RoadMap and Learning Objectives • Learn to use the basic UI widgets • Learn to switch Activities using Explicit Intent 3

Ul Development

UI Development 4

Basic Input Controls Input controls are used Button to take data from user Wic idgets Text field OFF Textview a Button Check Box Textview Large Medium Small RadioButton Button Smal OFF ˇ CheckBox, RadioButton a Spinner CheckedTextview Spinner o Text fields Dialogs 5

Basic Input Controls • Input controls are used to take data from user o Widgets ▪ TextView ▪ Button ▪ CheckBox ▪ RadioButton ▪ Spinner o Text Fields o Dialogs 5

Text Fields Text Fields allow users to type text in your application Text Fields have different types like Firstname Lastname Plain Text e Text Field o Person Name 55530100 o Password PAssword Password(Numeric) o email Lorem ipsum dolor sit met consectetur o Phone I Postal Address do esmod tempor o Postal Address 1200am 2011 o multiline text 工 Number Number(Signed) o Time I Number(Decimal) Auto CompleteTextView o Date Multi AutoCompleteTexctView MultiAutoComplete o Number(signed/Unsigned All of the Text Fields mentioned above are merely attributes of edit text http://developer.androidcom/guide/topics/ui/controls/text.html 6

Text Fields • Text Fields allow users to type text in your application. • Text Fields have different types like: o Plain Text o Person Name o Password o Email o Phone o Postal Address o Multiline Text o Time o Date o Number (Signed/Unsigned) • All of the Text Fields mentioned above are merely attributes of EditText 6 http://developer.android.com/guide/topics/ui/controls/text.html

Text view Textview is used to display text on screen a7:51 ol Edit Greeting o EditText. Button are direct subclasses of Hello World Textview Textview doesn 't allow editing in itself It works more like a label Click mel http://developer.androidcom/reference/android/widget/textview.html 7

Text View • TextView is used to display text on screen. o EditText, Button are direct subclasses of TextView. • TextView doesn't allow editing in itself • It works more like a label 7 http://developer.android.com/reference/android/widget/TextView.html

Buttons Buttons allows user to perform some action Android have following button types available, sequence iS Control Name(Class name o Button Button Off o Image Button(Image Button o Toggle Buttons(ToggleButton) ATTENDING? o Radio Buttons(radioButton) O Maybe ON All buttons have different classes and XML tags to represent them unlike the Text Fields(that had only one tag i.e. Edit Text) http://developer.androidcom/guide/topics/ui/controls/button.html 8

Buttons • Buttons allows user to perform some action. • Android have following button types available, sequence is Control Name (Class Name): o Button (Button) o Image Button (ImageButton) o Toggle Buttons (ToggleButton) o Radio Buttons (RadioButton) • All buttons have different classes and XML tags to represent them unlike the Text Fields (That had only one tag i.e. EditText) 8 http://developer.android.com/guide/topics/ui/controls/button.html

Pageview Image View is used to display an image Practises Can load images from various BEEN THERE sources, e.g., drawables/content providers Various other display options available like scaling tinting DONE THAT! 9

ImageView • ImageView is used to display an image. • Can load images from various sources, e.g., drawables/content providers. • Various other display options available like scaling & tinting. 9

6 Packages O com. exampl p□util Rjava co ActivityA Sb Activity B So ActivityC ta BuildConfig R java: hook the resources and java by b a drawable-hdpi b a drawable-ldpi □ drawable-mdpi providing each resource item an ID o drawable-xhdpi b a layout Ovals Reference a resource in java codes liBraries [.R . o : name of the package in which the resource is located (not required when referencing resources from your own package) : the resource filename without the extension or the android name attribute value in the xml element findviewbyId(r. id ***) identify a view on Xml by its id setContentView(R layout. ***): apply the layout for the content view 10

• Reference a resource in Java codes o : name of the package in which the resource is located (not required when referencing resources from your own package). o : resource type. o : the resource filename without the extension or the android:name attribute value in the XML element. R.java • R.java: hook the resources and java by providing each resource item an ID 10 [.]R.. • findViewById(R.id.***): identify a view on XML by its id • setContentView(R.layout.***): apply the layout for the content view

点击下载完整版文档(PPTX)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共81页,可试读20页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有