Skip to content

Instantly share code, notes, and snippets.

@udacityandroid
Last active May 3, 2023 20:38
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
  • Save udacityandroid/273e1273286e5169c87d to your computer and use it in GitHub Desktop.
Save udacityandroid/273e1273286e5169c87d to your computer and use it in GitHub Desktop.
Android for Beginners : Add the Chocolate Topping Checkbox Solution XML
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Toppings"
android:textAllCaps="true" />
<CheckBox
android:id="@+id/whipped_cream_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="24dp"
android:text="Whipped cream"
android:textSize="16sp" />
<CheckBox
android:id="@+id/chocolate_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="24dp"
android:text="Chocolate"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:text="Quantity"
android:textAllCaps="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:onClick="decrement"
android:text="-" />
<TextView
android:id="@+id/quantity_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="2"
android:textColor="@android:color/black"
android:textSize="16sp" />
<Button
android:layout_width="48dp"
android:layout_height="48dp"
android:onClick="increment"
android:text="+" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Order Summary"
android:textAllCaps="true" />
<TextView
android:id="@+id/order_summary_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="$10"
android:textColor="@android:color/black"
android:textSize="16sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:onClick="submitOrder"
android:text="Order" />
</LinearLayout>
</ScrollView>
@akarsh
Copy link

akarsh commented Jan 6, 2016

Nice it is helpful

@LucaMannella
Copy link

In the answer of the lesson you added a wrong line to the JavaDoc... You just copy and paste the prevoius @param line without modify it.

@danserb
Copy link

danserb commented Jan 31, 2017

When I try to create new checkbox with Chocolate it ruins my layout with increment quantity and increment and it shows the orderSummary into the quantity text view .. :( can't figure it out, please help.

@tamiromara
Copy link

@danserb people would be able to help you if you share your code.

@Irissm
Copy link

Irissm commented Mar 23, 2017

Thanks for the code to check if we are doing well ;)

@breakthedoor99
Copy link

Thanks a lot for this exercise, I got everything right, I didn't have to use your code. The answer to the question for this exercise, i have tried entering everything I know, i even copied the codes and still tells me it's wrong. I don't think I know what you want me to put it, I got everything right by fixing the chocolate topping and the java file. just the answer to you question in the classroom, I have no idea what you want me to put in.

@Maxwe1
Copy link

Maxwe1 commented Feb 8, 2018

Thanks for the code to check if we are doing well ;)

@Nogaeman
Copy link

Thanks Alot

@abdahma01
Copy link

nice ...done

@badrddinb
Copy link

Thanks

@sherifhisham
Copy link

thanks Katherine or Kat . great effort

@Fury4hwxc
Copy link

thanks 👍

@ehabpop
Copy link

ehabpop commented Jun 24, 2018

Thanks

@tooptooptoop
Copy link

thanks

@tooptooptoop
Copy link

thanks

@djalilo24
Copy link

xml

java**
CheckBox chocolate=(CheckBox)findViewById(R.id.check2);
boolean choco=chocolate.isChecked()

PriceMessge+="\nadd chocolate?"+choco;

@djalilo24
Copy link

xml

java
CheckBox chocolate=(CheckBox)findViewById(R.id.check2);
boolean choco=chocolate.isChecked()
PriceMessge+="\nadd chocolate?"+choco;

@mixspark
Copy link

thanks udacity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment