Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MOBAPP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
THONG Sylvain
MOBAPP
Commits
d85e3157
Commit
d85e3157
authored
4 months ago
by
COUCHET Thibaud
Browse files
Options
Downloads
Patches
Plain Diff
Snackbar complete
parent
8f762ab1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/fr/imt_atlantique/myfirstapplication/MainActivity.java
+48
-6
48 additions, 6 deletions
...va/fr/imt_atlantique/myfirstapplication/MainActivity.java
with
48 additions
and
6 deletions
app/src/main/java/fr/imt_atlantique/myfirstapplication/MainActivity.java
+
48
−
6
View file @
d85e3157
...
@@ -73,13 +73,53 @@ public class MainActivity extends AppCompatActivity {
...
@@ -73,13 +73,53 @@ public class MainActivity extends AppCompatActivity {
public
void
validateAction
(
View
v
){
public
void
validateAction
(
View
v
){
final
Snackbar
snackbar
=
Snackbar
.
make
(
findViewById
(
R
.
id
.
mainContent
),
"Snackbar de validation"
,
Snackbar
.
LENGTH_LONG
);
/*
final Snackbar snackbar = Snackbar.make(findViewById(R.id.mainContent), "Snackbar de validation", Snackbar.LENGTH_LONG);
snackbar.setAction("Dismiss", new View.OnClickListener() {
snackbar.setAction("Dismiss", new View.OnClickListener() {
@Override
@Override
public void onClick(View v) {
public void onClick(View v) {
snackbar.dismiss();
snackbar.dismiss();
}
}
});
});
snackbar.show();*/
// Récupérer les champs de texte
EditText
firstNameEditText
=
findViewById
(
R
.
id
.
firstNameEditText
);
EditText
lastNameEditText
=
findViewById
(
R
.
id
.
lastNameEditText
);
EditText
birthDateEditText
=
findViewById
(
R
.
id
.
birthDateEditText
);
EditText
birthCityEditText
=
findViewById
(
R
.
id
.
birthCityEditText
);
// Obtenir les valeurs saisies
String
firstName
=
firstNameEditText
.
getText
().
toString
();
String
lastName
=
lastNameEditText
.
getText
().
toString
();
String
birthDate
=
birthDateEditText
.
getText
().
toString
();
String
birthCity
=
birthCityEditText
.
getText
().
toString
();
// Récupérer les numéros de téléphone
LinearLayout
phonesLayout
=
findViewById
(
R
.
id
.
phonesLayout
);
int
phoneNumberCount
=
phonesLayout
.
getChildCount
()
-
1
;
// -1 pour la ligne "Ajouter un numéro"
StringBuilder
phoneNumbers
=
new
StringBuilder
();
for
(
int
i
=
1
;
i
<
phonesLayout
.
getChildCount
();
i
++)
{
// Commence à 1 pour ignorer la ligne "Ajouter un numéro"
View
phoneView
=
phonesLayout
.
getChildAt
(
i
);
EditText
phoneEditText
=
phoneView
.
findViewById
(
R
.
id
.
phoneNumberEditText
);
String
phoneNumber
=
phoneEditText
.
getText
().
toString
();
phoneNumbers
.
append
(
"\n- "
).
append
(
phoneNumber
);
}
// Construire le message complet
String
message
=
firstName
+
" "
+
lastName
+
" "
+
birthDate
+
" : "
+
birthCity
+
" ("
+
phoneNumberCount
+
") :"
+
phoneNumbers
.
toString
();
// Afficher le message dans une Snackbar ou un Toast
final
Snackbar
snackbar
=
Snackbar
.
make
(
findViewById
(
R
.
id
.
mainContent
),
message
,
Snackbar
.
LENGTH_LONG
);
snackbar
.
setAction
(
"Fermer"
,
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
snackbar
.
dismiss
();
}
});
snackbar
.
show
();
snackbar
.
show
();
}
}
public
void
resetAction
(
MenuItem
item
){
public
void
resetAction
(
MenuItem
item
){
...
@@ -108,11 +148,13 @@ public class MainActivity extends AppCompatActivity {
...
@@ -108,11 +148,13 @@ public class MainActivity extends AppCompatActivity {
viewGroup
.
addView
(
duplicatedView
);
viewGroup
.
addView
(
duplicatedView
);
}
}
public
void
removePhoneNumber
(
View
v
){
public
void
removePhoneNumber
(
View
v
)
{
ViewGroup
phonesLayout
=
(
ViewGroup
)
findViewById
(
R
.
id
.
phonesLayout
);
ViewGroup
phoneRow
=
(
ViewGroup
)
v
.
getParent
();
int
childCount
=
phonesLayout
.
getChildCount
();
if
(
phoneRow
!=
null
)
{
if
(
childCount
>
0
)
{
ViewGroup
parent
=
(
ViewGroup
)
phoneRow
.
getParent
();
phonesLayout
.
removeViewAt
(
childCount
-
1
);
if
(
parent
!=
null
)
{
parent
.
removeView
(
phoneRow
);
}
}
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment