SlideShare une entreprise Scribd logo
1  sur  9
Télécharger pour lire hors ligne
Avec le soutien de :
LiveCoding : Hello World avec Intents et Events
● Objectif : Première application interactive
○

Un premier écran avec un champ pour saisir son nom et un bouton
qui amène au deuxième écran

○

Un deuxième écran avec un Hello $NOM personnalisé

● Concepts à voir
○

Création d'une application avec plusieurs Activités

○

Création d'un Gabarit à plusieurs composants

○

Utilisation des Event Listeners pour écouter des Évenements

○

Utilisation des Intent pour changer d'Activité

Avec le soutien de :
LiveCoding : Hello World avec Intents et Events
● Code du LiveCoding : déppot GitHub

https://github.com/LostInBrittany/gdgrennes-androidbootcamp-HelloWorld

● Chaque step correspond à une branche
git checkout step-XX
Avec le soutien de :
Step-1 : Layout de l’Activity principale

● En utilisant le Designer d’Android Studio

Mais l’i18n, c’est où ?
Avec le soutien de :
Step-2 : i18n des chaînes

Avec le soutien de :
Step-3 : Création de HelloActivity

Avec le soutien de :
Step-4 : EventListener basique sur le bouton

Avec le soutien de :
Step-5 : Intent Filter & Intent
Dans HelloActivity
@Override
protected void onCreate(Bundle savedInstanceState) {

Dans le l’Activité principale

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello);

@Override
protected void onStart() {
super.onStart();

Bundle extras = getIntent().getExtras();
String name = extras.getString("name");

Button b = (Button)findViewById(R.id.buttonOK);
b.setOnClickListener(new View.OnClickListener() {

TextView nameLabel =

@Override

(TextView) findViewById(R.id.textHello);

public void onClick(View v) {

nameLabel.setText(nameLabel.getText()+" "+name);

EditText nameField =
(EditText) findViewById(R.id.editTextName)

}

String name = nameField.getText().toString();
Intent helloIntent =
new Intent("org.gdgrennes.bootcamp.android.HELLO");
helloIntent.putExtra("name", name);
startActivity(helloIntent);
}
});
}

Dans le Manifeste
<activity
android:name="org.gdgrennes.android.bootcamp.HelloActivity"
android:label="@string/title_activity_hello" >
<intent-filter>
<action android:name="org.gdgrennes.bootcamp.android.HELLO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

Avec le soutien de :
LiveCoding : Hello World avec Intents et Events

Avec le soutien de :

Contenu connexe

Plus de Horacio Gonzalez

Mixing Web Components - Best of Web Paris - 2016 06-09
Mixing Web Components - Best of Web Paris - 2016 06-09Mixing Web Components - Best of Web Paris - 2016 06-09
Mixing Web Components - Best of Web Paris - 2016 06-09Horacio Gonzalez
 
Polymer in the real life - Devoxx France - 2016 04-20
Polymer in the real life - Devoxx France - 2016 04-20Polymer in the real life - Devoxx France - 2016 04-20
Polymer in the real life - Devoxx France - 2016 04-20Horacio Gonzalez
 
Warp10: collect, store and manipulate sensor data - BreizhCamp - 2016 03-24
Warp10: collect, store and manipulate sensor data - BreizhCamp - 2016 03-24 Warp10: collect, store and manipulate sensor data - BreizhCamp - 2016 03-24
Warp10: collect, store and manipulate sensor data - BreizhCamp - 2016 03-24 Horacio Gonzalez
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptHoracio Gonzalez
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...Horacio Gonzalez
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...Horacio Gonzalez
 
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQLENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQLHoracio Gonzalez
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JSENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JSHoracio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQLENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQLHoracio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptHoracio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...Horacio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JSENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JSHoracio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...Horacio Gonzalez
 
Beyond Polymer - JUG Summer Camp - 2015-09-18
Beyond Polymer - JUG Summer Camp - 2015-09-18Beyond Polymer - JUG Summer Camp - 2015-09-18
Beyond Polymer - JUG Summer Camp - 2015-09-18Horacio Gonzalez
 
Mixing Web Components - Paris Web Components - 2015 09-16
Mixing Web Components - Paris Web Components - 2015 09-16 Mixing Web Components - Paris Web Components - 2015 09-16
Mixing Web Components - Paris Web Components - 2015 09-16 Horacio Gonzalez
 
Devoxx France - Web Components, Polymer et Material Design
Devoxx France -  Web Components, Polymer et Material DesignDevoxx France -  Web Components, Polymer et Material Design
Devoxx France - Web Components, Polymer et Material DesignHoracio Gonzalez
 
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...Horacio Gonzalez
 
2014 03-25 - GDG Nantes - Web Components avec Polymer
2014 03-25 - GDG Nantes - Web Components avec Polymer2014 03-25 - GDG Nantes - Web Components avec Polymer
2014 03-25 - GDG Nantes - Web Components avec PolymerHoracio Gonzalez
 
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidement
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidementENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidement
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidementHoracio Gonzalez
 
ENIB 2013-2014 - CAI Web #3: Groovy
ENIB 2013-2014 - CAI Web #3: GroovyENIB 2013-2014 - CAI Web #3: Groovy
ENIB 2013-2014 - CAI Web #3: GroovyHoracio Gonzalez
 

Plus de Horacio Gonzalez (20)

Mixing Web Components - Best of Web Paris - 2016 06-09
Mixing Web Components - Best of Web Paris - 2016 06-09Mixing Web Components - Best of Web Paris - 2016 06-09
Mixing Web Components - Best of Web Paris - 2016 06-09
 
Polymer in the real life - Devoxx France - 2016 04-20
Polymer in the real life - Devoxx France - 2016 04-20Polymer in the real life - Devoxx France - 2016 04-20
Polymer in the real life - Devoxx France - 2016 04-20
 
Warp10: collect, store and manipulate sensor data - BreizhCamp - 2016 03-24
Warp10: collect, store and manipulate sensor data - BreizhCamp - 2016 03-24 Warp10: collect, store and manipulate sensor data - BreizhCamp - 2016 03-24
Warp10: collect, store and manipulate sensor data - BreizhCamp - 2016 03-24
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
 
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQLENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JSENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
 
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQLENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
 
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JSENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
 
Beyond Polymer - JUG Summer Camp - 2015-09-18
Beyond Polymer - JUG Summer Camp - 2015-09-18Beyond Polymer - JUG Summer Camp - 2015-09-18
Beyond Polymer - JUG Summer Camp - 2015-09-18
 
Mixing Web Components - Paris Web Components - 2015 09-16
Mixing Web Components - Paris Web Components - 2015 09-16 Mixing Web Components - Paris Web Components - 2015 09-16
Mixing Web Components - Paris Web Components - 2015 09-16
 
Devoxx France - Web Components, Polymer et Material Design
Devoxx France -  Web Components, Polymer et Material DesignDevoxx France -  Web Components, Polymer et Material Design
Devoxx France - Web Components, Polymer et Material Design
 
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...
 
2014 03-25 - GDG Nantes - Web Components avec Polymer
2014 03-25 - GDG Nantes - Web Components avec Polymer2014 03-25 - GDG Nantes - Web Components avec Polymer
2014 03-25 - GDG Nantes - Web Components avec Polymer
 
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidement
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidementENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidement
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidement
 
ENIB 2013-2014 - CAI Web #3: Groovy
ENIB 2013-2014 - CAI Web #3: GroovyENIB 2013-2014 - CAI Web #3: Groovy
ENIB 2013-2014 - CAI Web #3: Groovy
 

Bootcamp d'Initiation à Android - 2013/11/30 - Live coding : Hello world! with intents and events

  • 2. LiveCoding : Hello World avec Intents et Events ● Objectif : Première application interactive ○ Un premier écran avec un champ pour saisir son nom et un bouton qui amène au deuxième écran ○ Un deuxième écran avec un Hello $NOM personnalisé ● Concepts à voir ○ Création d'une application avec plusieurs Activités ○ Création d'un Gabarit à plusieurs composants ○ Utilisation des Event Listeners pour écouter des Évenements ○ Utilisation des Intent pour changer d'Activité Avec le soutien de :
  • 3. LiveCoding : Hello World avec Intents et Events ● Code du LiveCoding : déppot GitHub https://github.com/LostInBrittany/gdgrennes-androidbootcamp-HelloWorld ● Chaque step correspond à une branche git checkout step-XX Avec le soutien de :
  • 4. Step-1 : Layout de l’Activity principale ● En utilisant le Designer d’Android Studio Mais l’i18n, c’est où ? Avec le soutien de :
  • 5. Step-2 : i18n des chaînes Avec le soutien de :
  • 6. Step-3 : Création de HelloActivity Avec le soutien de :
  • 7. Step-4 : EventListener basique sur le bouton Avec le soutien de :
  • 8. Step-5 : Intent Filter & Intent Dans HelloActivity @Override protected void onCreate(Bundle savedInstanceState) { Dans le l’Activité principale super.onCreate(savedInstanceState); setContentView(R.layout.activity_hello); @Override protected void onStart() { super.onStart(); Bundle extras = getIntent().getExtras(); String name = extras.getString("name"); Button b = (Button)findViewById(R.id.buttonOK); b.setOnClickListener(new View.OnClickListener() { TextView nameLabel = @Override (TextView) findViewById(R.id.textHello); public void onClick(View v) { nameLabel.setText(nameLabel.getText()+" "+name); EditText nameField = (EditText) findViewById(R.id.editTextName) } String name = nameField.getText().toString(); Intent helloIntent = new Intent("org.gdgrennes.bootcamp.android.HELLO"); helloIntent.putExtra("name", name); startActivity(helloIntent); } }); } Dans le Manifeste <activity android:name="org.gdgrennes.android.bootcamp.HelloActivity" android:label="@string/title_activity_hello" > <intent-filter> <action android:name="org.gdgrennes.bootcamp.android.HELLO" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> Avec le soutien de :
  • 9. LiveCoding : Hello World avec Intents et Events Avec le soutien de :