Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mobile Applications (Android Programming)

Similar presentations


Presentation on theme: "Mobile Applications (Android Programming)"— Presentation transcript:

1 Mobile Applications (Android Programming)
Semester II Dr. Saman Mirza Abdullah

2 Class Objective The objective of this class is:
To learn how Android applications store and access important resources such as strings, graphics, and other data. To learn how to organize Android resources within the project files. To learn the localization and configuration of different devices. Mobile Application - Ishik

3 Resources Directory Mobile Application - Ishik

4 Resources and Codes Good developers not put data within the source code. Instead, data are accessed programmatically. Storing application resources in a single place Is a more organized approach to development, Makes the code more readable and maintainable Localization (adaption) of applications for different languages and devices. Mobile Application - Ishik

5 Resources All Android application are composed of two things:
Functionalities: Is a code that determines the behaviors of the application, such algorithms or models for problems. Resources: They are data or information accessed by the source code, such as string, style and themes, dimensions, image and icons, audio files, vedios, and other data. Mobile Application - Ishik

6 Storing Resources Resources are separately stored from .java class files They are stored in XML, but still row data and graphs are accepted. They are stored in /res directory File names should be lowercase. No duplicated. Mobile Application - Ishik

7 Resource Directories Mobile Application - Ishik

8 Resource Type and File Hierarchy
Mobile Application - Ishik

9 Default VS Alternative Resources
There are many criterion for storing resources. Default resources are those that stored automatically by the created applications. Creating some special resources are needed in some cases: Internationalization, when an application needed to work with multi-languages. Localization, when there is a need to run an application smoothly on different devices and orientations. Mobile Application - Ishik

10 Alternative Resources: Examples
An application with different graphical size. /res/drwable-ldpi/mylogo.png (low-density screen) /res/drwable-mdpi/mylogo.png (medium-density screen) /res/drwable-hdpi/mylogo.png (high-density screen) /res/drwable-xhdpi/mylogo.png (extra high-density screen) /res/drwable-xxhdpi/mylogo.png (extra extra high-density screen) Application for different orientations: /res/layout-port/main.xml (layout loaded in portiere) /res/layout-land/main.xml (layout loaded in landscape) Mobile Application - Ishik

11 Access Resources All resource files will be compiled and seen as R.Java class file and it is sub-classes. The file will be automatically generated when any resources are added. Through this files the content is accessed. Example: A String named strHello defined within the resource file called /res/values/string.mls Can be accessed R.string.strHellow  doesn't return data. String mystring = getResource().getString (R.String.strHello) Mobile Application - Ishik

12 Accessing Resource Programmatically
Using String resources programmatically: Mobile Application - Ishik

13 String Resources Using Bold, Italic, and underline.
Mobile Application - Ishik

14 Working with Images Applications often include visual elements such as icons and graphics. Android supports several image formats. can be directly included as resources for your application. All resource filenames must be lowercase and simple Mobile Application - Ishik

15 List of Image Formats Mobile Application - Ishik

16 Accessing Image Resource
Image resources are simply another kind of Drawable called a BitmapDrawable. For Accessing, mostly it needs only the resource ID of the image. It can be accessed directly using BitmapDrawable function. Mobile Application - Ishik

17 Color State List Some time it needs to color an object based on state of the object. Could be done by special recourse called selector. Example: A Button control may need to by gray when disable, green when activated, and yellow when processed. Mobile Application - Ishik

18 Color State List Mobile Application - Ishik

19 Color State Defining Mobile Application - Ishik

20 Button State Color we define a Button and set the textColor
the state list resource file text_color.xml is defined as list of state color. Mobile Application - Ishik

21 Class End Mobile Application - Ishik


Download ppt "Mobile Applications (Android Programming)"

Similar presentations


Ads by Google