SlideShare une entreprise Scribd logo
GDG Rennes - Bootcamp Initiation Android - Hello World with Events and Intents
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é
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
Step-1 : Layout de l’Activity principale
● En utilisant le Designer d’Android Studio
Mais l’i18n, c’est où ?
Step-2 : i18n des chaînes
Step-3 : Création de HelloActivity
Step-4 : EventListener basique sur le bouton
Step-5 : Intent Filter & Intent
Dans le l’Activité principale
@Override
protected void onStart() {
super.onStart();
Button b = (Button)findViewById(R.id.buttonOK);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
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>
Dans HelloActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello);
Bundle extras = getIntent().getExtras();
String name = extras.getString("name");
TextView nameLabel =
(TextView) findViewById(R.id.textHello);
nameLabel.setText(nameLabel.getText()+" "+name);
}
LiveCoding : Hello World avec Intents et Events

Contenu connexe

PDF
Bootcamp d'Initiation à Android - 2013/11/30 - Live coding : Hello world!
PDF
Bootcamp d'Initiation à Android - 2013/11/30
PDF
GDG Rennes - Bootcamp Initiation Android - Théorie
PDF
GDG Rennes - Bootcamp Initiation Android - Hello World
PDF
FinistJUG - J’ai besoin d’une appli web rapidement
PDF
Enib cours c.a.i. web - séance #5 : td grails
PDF
20091006 Dev Forum Fr 001Introduction à GWT en utilisant AppCase SDK
PDF
Android studio 2.0
Bootcamp d'Initiation à Android - 2013/11/30 - Live coding : Hello world!
Bootcamp d'Initiation à Android - 2013/11/30
GDG Rennes - Bootcamp Initiation Android - Théorie
GDG Rennes - Bootcamp Initiation Android - Hello World
FinistJUG - J’ai besoin d’une appli web rapidement
Enib cours c.a.i. web - séance #5 : td grails
20091006 Dev Forum Fr 001Introduction à GWT en utilisant AppCase SDK
Android studio 2.0

Similaire à GDG Rennes - Bootcamp Initiation Android - Hello World with Events and Intents (6)

PDF
5.ateliers avancés
PDF
TP_1.pdf
PDF
Développer une application android en 2015
PDF
Android - Tp1 - installation et démarrage
PPTX
IoT.pptx
PDF
Git & Rstudio vincent guyader
5.ateliers avancés
TP_1.pdf
Développer une application android en 2015
Android - Tp1 - installation et démarrage
IoT.pptx
Git & Rstudio vincent guyader
Publicité

Plus de Horacio Gonzalez (20)

PDF
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
PDF
But there is no web component for that - Web Components Remote Conference - 2...
PDF
Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27
PDF
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 2/3 - HTML5, CSS3, Twitter B...
PDF
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
PDF
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
PDF
Mixing Web Components - Best of Web Paris - 2016 06-09
PDF
Polymer in the real life - Devoxx France - 2016 04-20
PDF
Warp10: collect, store and manipulate sensor data - BreizhCamp - 2016 03-24
PDF
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
PDF
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
PDF
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
PDF
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
PDF
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
PDF
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
PDF
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
PDF
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
PDF
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
PDF
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
PDF
Beyond Polymer - JUG Summer Camp - 2015-09-18
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
But there is no web component for that - Web Components Remote Conference - 2...
Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 2/3 - HTML5, CSS3, Twitter B...
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
Mixing Web Components - Best of Web Paris - 2016 06-09
Polymer in the real life - Devoxx France - 2016 04-20
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 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 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 - S01E01- MongoDB and NoSQL
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 1/3 - HTTP, HTML, CSS, JS
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
Beyond Polymer - JUG Summer Camp - 2015-09-18
Publicité

GDG Rennes - Bootcamp Initiation Android - Hello World with Events and Intents

  • 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é
  • 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
  • 4. Step-1 : Layout de l’Activity principale ● En utilisant le Designer d’Android Studio Mais l’i18n, c’est où ?
  • 5. Step-2 : i18n des chaînes
  • 6. Step-3 : Création de HelloActivity
  • 7. Step-4 : EventListener basique sur le bouton
  • 8. Step-5 : Intent Filter & Intent Dans le l’Activité principale @Override protected void onStart() { super.onStart(); Button b = (Button)findViewById(R.id.buttonOK); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { 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> Dans HelloActivity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hello); Bundle extras = getIntent().getExtras(); String name = extras.getString("name"); TextView nameLabel = (TextView) findViewById(R.id.textHello); nameLabel.setText(nameLabel.getText()+" "+name); }
  • 9. LiveCoding : Hello World avec Intents et Events