YouSub
Untitled

en English

Untitled English subtitles

0 downloads · 45 lines · added Dec 7, 2015

Report a problem
What's wrong?
Advertisement

English transcript

First we need to modify the activity main layout so
that we can add the text views for price.
If the device preview isn't showing already,
you can click on this link here that says Preview in order to make it appear.
Now, when we change the XML, we can just see it update automatically, here.
In this screen shot we provided for
you, the price was presented in a similar way to the quantity.
We have a header, as well as a text view, to show the value.
So we can just copy over these two text view elements and
then paste it beneath it.
Now we just need to tweak the values to fit our scenario.
Instead of quantity, it should say price.
And, we should also change the ID to be price text view.
You can have two views with the same ID.
But, anyways, in the quiz, we told you to change this to be price text view.
So, it would match our code.
There. And that makes the error go away.
Okay, looking at the preview, we have the price header, and zero beneath it.
We also want to just change this just to be zero dollars.
And you can use your own currency symbol if you want.
The header is in all caps and
the actual price value has the text size of 16 sp and a black text color.
That looks good so far, except I do notice there needs to be a little
more vertical space between the price header and the quantity value.
I'm just going to change all the views so
that they have a margin top, value of 16dp.
And then instead of margin bottom here, I'm just going to do, margin top,
16, and that actually fixes it.
Cool.
Now all the views are evenly spaced apart.
Once you think the XML is in a good state,
then you can just run it on your device.
Cool, and that looks good.
Let's work on the MainActivity file now.
If this Android DDMS window pops up, you can just collapse it using this arrow.
In the MainActivity, we asked you to copy and
paste the displayPrice method that we gave you.
Hopefully, you also modified your Android Studio preferences
to automatically import things if they were unambiguous.
That would help resolve the problem of it not knowing what number format
referred to.
But now with the import statement, the app knows that number format is
something that's provided automatically by Java to help format numbers.
Then for the last step, we modify the submit order method, so that when
the button is clicked, we display the quantity and also display the price.

Need subtitles from another video?