16 !"# $%&''()&''*+,""# */()')*(01/(')')* 2 344##4# & 01#5 & Resources and Internaonalizaon 67,)6899# :;!:6,$< ",=,>=6# ?:,< "6,:$::@#.$, !A,@$:# 344##4$444)0(# B 01#5 B Using Resources !!:non-code assets A9# CResources9DA9$ :$Context.getResources()# ,source tree 9# E 01#5 E Copy/Paste Resources CA6 res/F# Resources are compiled into the nal APK le. A,R, :# $6:6 G 01#5 G 1 01#5 1 9:>9 $$#!6 / 01#5 / Examples# : : c:\Android\pla"orms\android-1.5\data\res\ ( 01#5 ( More Examples# ApiDemos9# :#H: c:\Android\pla"orms\android-1.6\samples\ How to install the App: H)IA)I=F)IAndroid=F)I .JCreate project form exisng sourceJ .ApiDemos :7$6A:F8 * 01#5 * Java Statements for Using Resources $ setContentView(R.layout.main); setContentView(R.layout.screen2); 0' 01#5 0' Java Statements for Using Resources $String:44K String msg = this.getString(R.string.color_prompt); <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hola Mundo!, ResourceDemo1!</string> <string name="app_name">ResourceDemo1</string> <string name="good_bye">Hasta luego</string> <string name="color_caption">Color:</string> <string name="color_prompt">Seleccione un Color</string> <string name="planet_caption"> <b>Planeta </b>Planeta <i>Planeta </i><u>Planeta: </u></string> <string name="planet_prompt">Seleccione un Planeta</string> </resources> /res/values/strings.xml [...]... ArrayAdapter.createFromResource( this, R.array.planets, android. R.layout.simple_spinner_item); adapter.setDropDownViewResource( android. R.layout.simple_spinner_dropdown_item); s2.setAdapter(adapter); } } 17 16 Android – Resources Android Resources mmmm 18 16 Android – Resources Android Resources mmmm 19 16 Android – Resources Android Resources mmmm 20 21 16 Android – Resources Resources Questions ? 22 ... Resources Android Resources Example1 Using Embedded Resources (drawable, string, array) 15 16 Android – Resources Android Resources Example1 Using Embedded Resources (drawable, string, array) // using Resources (adapted from Android - ApiDemos) package cis493 .resources; import android. app.Activity; import android. os.Bundle; import android. widget.ArrayAdapter; import android. widget.EditText; import android. widget.ImageView;... imageView1.setImageResource( R.drawable .android_ green_3d); 13 16 Android – Resources Android Resources Example1 Using Embedded Resources (drawable, string, array) #7f00 #770000ff As in HTML a string using , , modifiers will be rendered in: bold, italics, and, underlined modes In our example: Planeta Planeta Planeta Planeta 11 16 Android – Resources Android Resources Java Statements for Using Resources Retrieving Array Resources from: res/values/… /res/values/arrays.xml . xmlns :android= "http://schemas .android. com/apk/res /android& quot; android: orientation="vertical" android: padding="10dip" android: layout_width="fill_parent" android: layout_height="fill_parent" . M$7A,$,8# // using Resources (adapted from Android - ApiDemos) package cis493 .resources; import android. app.Activity; import android. os.Bundle; import android. widget.ArrayAdapter; import android. widget.EditText; import. <Spinner android: id="@+id/spinner2" android: layout_width="fill_parent" android: layout_height="wrap_content" android: drawSelectorOnTop="true" android: prompt="@string/planet_prompt"