Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CPTR405
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kaelan Willauer
CPTR405
Commits
9a768c13
Commit
9a768c13
authored
Apr 12, 2021
by
Kaelan Willauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bugggg
parent
c60b7ee8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
+18
-12
app/src/main/java/com/zybooks/pizzaparty/MainActivity.java
app/src/main/java/com/zybooks/pizzaparty/MainActivity.java
+16
-10
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_main.xml
+2
-2
No files found.
app/src/main/java/com/zybooks/pizzaparty/MainActivity.java
View file @
9a768c13
...
...
@@ -52,7 +52,8 @@ public class MainActivity extends AppCompatActivity {
@Override
public
void
afterTextChanged
(
Editable
s
)
{
mNumPizzasTextView
.
setText
(
""
);
Log
.
d
(
TAG
,
"afterTextChanged was called"
);
// mNumPizzasTextView.setText("");
}
});
...
...
@@ -61,13 +62,14 @@ public class MainActivity extends AppCompatActivity {
R
.
array
.
hunger_array
,
android
.
R
.
layout
.
simple_spinner_item
);
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
mHowHungrySpinner
.
setAdapter
(
adapter
);
mHowHungrySpinner
.
setSelection
(
0
,
false
);
// mHowHungrySpinner.setSelection(0,false); // does not work as intended?
mHowHungrySpinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
String
item
=
(
String
)
parent
.
getItemAtPosition
(
position
);
Toast
.
makeText
(
MainActivity
.
this
,
item
,
Toast
.
LENGTH_SHORT
).
show
();
mNumPizzasTextView
.
setText
(
""
);
Log
.
d
(
TAG
,
"onItemSelected was called"
);
// mNumPizzasTextView.setText("");
}
@Override
...
...
@@ -88,13 +90,17 @@ public class MainActivity extends AppCompatActivity {
}
// Get hunger level selection
int
checkedId
=
mHowHungrySpinner
.
getId
();
// I didn't know what to do after updating to mHowHungrySpinner
PizzaCalculator
.
HungerLevel
hungerLevel
=
PizzaCalculator
.
HungerLevel
.
RAVENOUS
;
if
(
checkedId
==
R
.
id
.
hunger_spinner
)
{
hungerLevel
=
PizzaCalculator
.
HungerLevel
.
LIGHT
;
}
else
if
(
checkedId
==
R
.
id
.
hunger_spinner
)
{
PizzaCalculator
.
HungerLevel
hungerLevel
=
PizzaCalculator
.
HungerLevel
.
LIGHT
;
switch
(
mHowHungrySpinner
.
getSelectedItemPosition
())
{
case
1
:
hungerLevel
=
PizzaCalculator
.
HungerLevel
.
MEDIUM
;
break
;
case
2
:
hungerLevel
=
PizzaCalculator
.
HungerLevel
.
RAVENOUS
;
break
;
default
:
hungerLevel
=
PizzaCalculator
.
HungerLevel
.
LIGHT
;
break
;
}
// Get the number of pizzas needed
...
...
app/src/main/res/layout/activity_main.xml
View file @
9a768c13
...
...
@@ -53,11 +53,11 @@
<TextView
android:id=
"@+id/answerTextView"
android:text=
"@string/total_pizzas"
android:layout_width=
"
wrap_cont
ent"
android:layout_width=
"
match_par
ent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"20dp"
android:textSize=
"24sp"
app:layout_constraintLeft_toRightOf=
"
parent
"
app:layout_constraintLeft_toRightOf=
"
@id/hunger_spinner
"
app:layout_constraintTop_toBottomOf=
"@id/hunger_spinner"
android:layout_marginLeft=
"5dp"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment