1. Android Bootcamp Elaborado (con adaptaciones) a partir de los tutoriales: http://developer.android.com/resources/tutorials/hello-world.html http://developer.android.com/resources/tutorials/views/index.html
34. Experimento 1 Porque Android hace "Activity Lifecycle Management" y puede mantener activas o cerrar Activities conforme la necesidad
35. Experimento 2 Cerrar la aplicación (oprimiendo "Home") Hacer Force Close a traves del menú Menu -> Settings -> Applications -> Manage Apps -> Hello World -> Force Close Arrancarla nuevamente desde el menú de aplicaciones. ¿Cuál es el resultado?
44. El "Toast" que aparece cuando se hace click en la lista es aburrido... ¿C ó mo se puede implementar una búsqueda en la Web en lugar del Toast?
45. ... HelloActivity.java [Código: 7.txt] public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { Uri uri = Uri. parse ( "http://en.wikipedia.org/" + "wiki/" + Uri. encode ( countries .get(pos), null )); Intent intent = new Intent( Intent. ACTION_VIEW , uri); startActivity(intent); }
onCreate() Called when the activity is first created. This is where you should do all of your normal static set up: create views, bind data to lists, etc. This method also provides you with a Bundle containing the activity's previously frozen state, if there was one. Always followed by onStart(). setContentView(): Set the activity content to an explicit view. This view is placed directly into the activity's view hierarchy. It can itself be a complex view hierarchy. link to http://developer.android.com/images/activity_lifecycle.png?
fill_parent : means that the view wants to be as big as its parent (minus padding) wrap_content : means that the view wants to be just big enough to enclose its content (plus padding) String Resources: In Java: R.string. string_name In XML:@string/ string_name
dp: Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both &quot;dip&quot; and &quot;dp&quot;, though &quot;dp&quot; is more consistent with &quot;sp&quot;. sp: Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.
@+id/ means that we are creating this id in the namespace of our application
R.id.mylistview references entity declared on Resource file Toast: A toast is a view containing a quick little message for the user. The toast class helps you create and show those. ArrayAdapter: A concrete BaseAdapter that is backed by an array of arbitrary objects. By default this class expects that the provided resource id references a single TextView. If you want to use a more complex layout, use the constructors that also takes a field id. That field id should reference a TextView in the larger layout resource.
Note that the width of EditText is defined in sp
?
getPreferences() : Retrieve a SharedPreferences object for accessing preferences that are private to this activity. MODE_PRIVATE : File creation mode: the default mode, where the created file can only be accessed by the calling application (or all applications sharing the same user ID). MODE_WORLD_READABLE: File creation mode: allow all other applications to have read access to the created file MODE_WORLD_WRITABLE: File creation mode: allow all other applications to have write access to the created file.
Second argument in sp.getString(&quot;countries&quot;, &quot;Brazil;Argentina;Mexico&quot;); is the default value
Intent: An intent is an abstract description of an operation to be performed. An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed. The primary pieces of information in an intent are: action -- The general action to be performed, such as ACTION_VIEW , ACTION_EDIT , ACTION_MAIN , etc. data -- The data to operate on, such as a person record in the contacts database, expressed as a Uri .