Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
R4A11_Sujet_CTP_2025
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
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
Enzo Lamour
R4A11_Sujet_CTP_2025
Commits
df791aaa
Commit
df791aaa
authored
1 month ago
by
Enzo Lamour
Browse files
Options
Downloads
Patches
Plain Diff
Q5
parent
5e8590fc
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/iutlille/ctp_2025/MainActivity.java
+39
-1
39 additions, 1 deletion
app/src/main/java/fr/iutlille/ctp_2025/MainActivity.java
with
39 additions
and
1 deletion
app/src/main/java/fr/iutlille/ctp_2025/MainActivity.java
+
39
−
1
View file @
df791aaa
package
fr.iutlille.ctp_2025
;
import
static
android
.
media
.
CamcorderProfile
.
get
;
import
androidx.annotation.NonNull
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.recyclerview.widget.DividerItemDecoration
;
...
...
@@ -7,9 +9,12 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import
androidx.recyclerview.widget.RecyclerView
;
import
android.os.Bundle
;
import
android.view.ContextMenu
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.AdapterView
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
android.widget.Button
;
...
...
@@ -24,6 +29,9 @@ public class MainActivity extends AppCompatActivity {
public
class
ParticipantAdapter
extends
RecyclerView
.
Adapter
<
ParticipantViewHolder
>
{
private
List
<
Participant
>
participantsList
;
public
static
final
int
MENU_DELETE
=
1
;
private
AdapterView
.
OnItemClickListener
listener
;
ParticipantAdapter
(){}
...
...
@@ -56,12 +64,41 @@ public class MainActivity extends AppCompatActivity {
TextView
text1
;
TextView
text2
;
public
static
final
int
MENU_DELETE
=
1
;
private
AdapterView
.
OnItemClickListener
listener
;
public
ParticipantViewHolder
(
View
itemView
)
{
super
(
itemView
);
text1
=
itemView
.
findViewById
(
android
.
R
.
id
.
text1
);
text2
=
itemView
.
findViewById
(
android
.
R
.
id
.
text2
);
itemView
.
setOnCreateContextMenuListener
(
this
::
onCreateContextMenu
);
}
}
public
void
onClick
(
View
v
)
{
if
(
listener
!=
null
)
listener
.
onItemClick
(
getAbsoluteAdapterPosition
());
}
private
void
onCreateContextMenu
(
ContextMenu
menu
,
View
v
,
ContextMenu
.
ContextMenuInfo
menuInfo
){
int
position
=
getAbsoluteAdapterPosition
();
menu
.
add
(
Menu
.
NONE
,
MENU_DELETE
,
position
,
"Delete"
);
menu
.
setHeaderTitle
(
ui
.
ParticipantList
.
toString
());
}
private
int
getAbsoluteAdapterPosition
()
{
}
public
void
setOnItemClickListener
(
AdapterView
.
OnItemClickListener
l
)
{
this
.
listener
=
l
;
}
public
void
onBindViewHolder
(
@NonNull
ParticipantViewHolder
holder
,
int
position
)
{
Participant
participant
=
model
.
getParticipant
(
position
);
holder
.
setOnItemClickListener
(
listener
);
}}
private
ActivityMainBinding
ui
;
private
ModelApplication
model
;
...
...
@@ -105,4 +142,5 @@ public class MainActivity extends AppCompatActivity {
model
.
computeBalance
();
ui
.
ParticipantList
.
getAdapter
().
notifyDataSetChanged
();
}
}
\ 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