Commit 9a768c13 authored by Kaelan Willauer's avatar Kaelan Willauer

fixed bugggg

parent c60b7ee8
...@@ -52,7 +52,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -52,7 +52,8 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
mNumPizzasTextView.setText(""); Log.d(TAG, "afterTextChanged was called");
// mNumPizzasTextView.setText("");
} }
}); });
...@@ -61,13 +62,14 @@ public class MainActivity extends AppCompatActivity { ...@@ -61,13 +62,14 @@ public class MainActivity extends AppCompatActivity {
R.array.hunger_array, android.R.layout.simple_spinner_item); R.array.hunger_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mHowHungrySpinner.setAdapter(adapter); mHowHungrySpinner.setAdapter(adapter);
mHowHungrySpinner.setSelection(0,false); // mHowHungrySpinner.setSelection(0,false); // does not work as intended?
mHowHungrySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { mHowHungrySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String item = (String)parent.getItemAtPosition(position); String item = (String)parent.getItemAtPosition(position);
Toast.makeText(MainActivity.this, item, Toast.LENGTH_SHORT).show(); Toast.makeText(MainActivity.this, item, Toast.LENGTH_SHORT).show();
mNumPizzasTextView.setText(""); Log.d(TAG, "onItemSelected was called");
// mNumPizzasTextView.setText("");
} }
@Override @Override
...@@ -88,13 +90,17 @@ public class MainActivity extends AppCompatActivity { ...@@ -88,13 +90,17 @@ public class MainActivity extends AppCompatActivity {
} }
// Get hunger level selection // Get hunger level selection
int checkedId = mHowHungrySpinner.getId(); // I didn't know what to do after updating to mHowHungrySpinner PizzaCalculator.HungerLevel hungerLevel = PizzaCalculator.HungerLevel.LIGHT;
PizzaCalculator.HungerLevel hungerLevel = PizzaCalculator.HungerLevel.RAVENOUS; switch (mHowHungrySpinner.getSelectedItemPosition()) {
if (checkedId == R.id.hunger_spinner) { case 1:
hungerLevel = PizzaCalculator.HungerLevel.LIGHT; hungerLevel = PizzaCalculator.HungerLevel.MEDIUM;
} break;
else if (checkedId == R.id.hunger_spinner) { case 2:
hungerLevel = PizzaCalculator.HungerLevel.MEDIUM; hungerLevel = PizzaCalculator.HungerLevel.RAVENOUS;
break;
default:
hungerLevel = PizzaCalculator.HungerLevel.LIGHT;
break;
} }
// Get the number of pizzas needed // Get the number of pizzas needed
......
...@@ -53,11 +53,11 @@ ...@@ -53,11 +53,11 @@
<TextView <TextView
android:id="@+id/answerTextView" android:id="@+id/answerTextView"
android:text="@string/total_pizzas" android:text="@string/total_pizzas"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:textSize="24sp" android:textSize="24sp"
app:layout_constraintLeft_toRightOf="parent" app:layout_constraintLeft_toRightOf="@id/hunger_spinner"
app:layout_constraintTop_toBottomOf="@id/hunger_spinner" app:layout_constraintTop_toBottomOf="@id/hunger_spinner"
android:layout_marginLeft="5dp"/> android:layout_marginLeft="5dp"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment