0% found this document useful (0 votes)
3 views3 pages

Android Java Guide Complet

This document provides a step-by-step guide for creating an Android application using Java, covering local database integration, user data input and display, activity navigation, and XML layout design. It includes detailed instructions for setting up the project, creating layouts for the main and second activities, and implementing Java code for functionality. Key components include EditText, Button, TextView, and ListView elements in the layout.

Uploaded by

jeanpaultogbe9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Android Java Guide Complet

This document provides a step-by-step guide for creating an Android application using Java, covering local database integration, user data input and display, activity navigation, and XML layout design. It includes detailed instructions for setting up the project, creating layouts for the main and second activities, and implementing Java code for functionality. Key components include EditText, Button, TextView, and ListView elements in the layout.

Uploaded by

jeanpaultogbe9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Cours Complet Android Studio (Java)

Ce document guide étape par étape la création d'une application Android en Java avec :

1. Base de données locale (SQLite)

2. ListView simple et avec images

3. Saisie et affichage de données utilisateur

4. Navigation entre pages (activités)

5. Layout XML complet

1. Création du projet Android


- Ouvre Android Studio > New Project > Empty Activity

- Nom du projet : MonApp

- Langage : Java

- Minimum SDK : API 21 ou supérieur

2. Layout XML (activity_main.xml)

<LinearLayout xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">

<EditText
android:id="@+id/nameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Entrez votre nom" />

<Button
android:id="@+id/submitBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Soumettre" />

<TextView
android:id="@+id/resultText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />

<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
3. Layout pour ListView avec image (row_layout.xml)

<LinearLayout xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">

<ImageView
android:id="@+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@mipmap/ic_launcher" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:textSize="16sp" />
</LinearLayout>

4. Code Java pour affichage ([Link])

public class MainActivity extends AppCompatActivity {


EditText nameInput;
Button submitBtn;
TextView resultText;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);

nameInput = findViewById([Link]);
submitBtn = findViewById([Link]);
resultText = findViewById([Link]);

[Link](v -> {
String name = [Link]().toString();
[Link]("Bienvenue " + name);

Intent i = new Intent([Link], [Link]);


[Link]("userName", name);
startActivity(i);
});
}
}

5. Deuxième page : [Link]

public class SecondActivity extends AppCompatActivity {


TextView welcomeText;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_second);

welcomeText = findViewById([Link]);
String name = getIntent().getStringExtra("userName");
[Link]("Hello " + name + ", vous êtes sur la 2ème page");
}
}

6. Layout de la deuxième activité (activity_second.xml)

<LinearLayout xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:padding="16dp">

<TextView
android:id="@+id/welcomeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
</LinearLayout>

You might also like