File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
ReciclerView/app/src/main
java/space/harbour/reciclerviewsample Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ private void populateSuperheroList() {
4949 public void onClick (View view ) {
5050 // Get selected hero from the list
5151 Superhero selectedCharacter = adapter .getSelectedSuperhero ();
52+ if (selectedCharacter == null )
53+ Toast .makeText (this , R .string .a_superhero_must_be_selected , Toast .LENGTH_LONG ).show ();
54+
5255 Toast .makeText (this , selectedCharacter .getFullName (), Toast .LENGTH_SHORT ).show ();
5356 }
5457}
Original file line number Diff line number Diff line change 11package space .harbour .reciclerviewsample ;
22
3+ import lombok .AllArgsConstructor ;
4+ import lombok .Data ;
5+ import lombok .NoArgsConstructor ;
6+
37/**
48 * Superhero
59 */
@@ -18,15 +22,28 @@ public String getName() {
1822 return name ;
1923 }
2024
25+ public void setName (String name ) {
26+ this .name = name ;
27+ }
28+
2129 public String getSurname () {
2230 return surname ;
2331 }
2432
33+ public void setSurname (String surname ) {
34+ this .surname = surname ;
35+ }
36+
2537 public String getSuperHeroeName () {
2638 return superHeroeName ;
2739 }
2840
41+ public void setSuperHeroeName (String superHeroeName ) {
42+ this .superHeroeName = superHeroeName ;
43+ }
44+
2945 public String getFullName () {
3046 return name + " " + surname ;
47+
3148 }
3249}
Original file line number Diff line number Diff line change 11<resources >
22 <string name =" app_name" >ReciclerViewSample</string >
3+ <string name =" a_superhero_must_be_selected" >A superhero must be selected</string >
34</resources >
You can’t perform that action at this time.
0 commit comments