Calculator App Example Android Studio Tutorial

  Рет қаралды 87,564

Code With Cal

Code With Cal

Күн бұрын

Todays tutorial we are building a simple calculator app in Android Studio using Java. A fantastic beginner programming project. We build a simple android studio project called Calculator App Example.
We use Linear Layouts and Android weight to ensure our calculator app works with multiple screen sizes. The heavy lifting of the math's is done by a third party JavaScript library link below. Then in the final part of the tutorial I give an example of how you can build upon the basic calculator by adding a bit of code to make the "power of button" and the brackets work.
Calculator App Source Code:
github.com/codeWithCal/Calcul...
Rhino Script Engine:
github.com/APISENSE/rhino-and...
⏱️TIMESTAMPS
00:00 - Intro
00:35 - Layout XML
05:17 - Simple Calculator Java
08:24 - () ^ Java
#AndroidStudio #CalculatorApp #AppDevelopment

Пікірлер: 93
@CodeWithCal
@CodeWithCal 3 жыл бұрын
iOS Calculator App Tutorial kzfaq.info/get/bejne/d5iXerGFsNXDoWw.html
@woojuspace7281
@woojuspace7281 3 жыл бұрын
This is an amazing tutorial with a simple-looking good layout! Thank you so much!
@emmanuelpedroza2421
@emmanuelpedroza2421 3 жыл бұрын
dude! cal! i love your video! i like the way you speed/fast forward on things! this helps me! thanks!!!
@x55554
@x55554 3 жыл бұрын
Great tutorial! Cheers for the rhino engine I had no idea there was such thing
@ericlareza4905
@ericlareza4905 3 жыл бұрын
Bro, amazing tutorial. Thank you, am your new subscriber! Kudos!
@shubhankaringale278
@shubhankaringale278 2 жыл бұрын
Great help thanks... needed more videos like that.
@AsadKhan-rl5mc
@AsadKhan-rl5mc 2 жыл бұрын
Oh Man, You made my work easy..😍
@sebastianbermudezvasquez2848
@sebastianbermudezvasquez2848 2 жыл бұрын
Grande hermano, eres el mejor se te quiere
@sathwikasreeravipati1416
@sathwikasreeravipati1416 2 жыл бұрын
Thank u so much amazing tutorial
@amiel6057
@amiel6057 3 жыл бұрын
Thank you so much!! You saved me!
@CodeWithCal
@CodeWithCal 3 жыл бұрын
Glad I could help :)
@asadbekaminboyev3311
@asadbekaminboyev3311 2 жыл бұрын
Your video lesson was very helpful to me
@zongsian5268
@zongsian5268 3 жыл бұрын
thank you!
@chichigorgor3184
@chichigorgor3184 3 жыл бұрын
lovely video. thank you
@CodeWithCal
@CodeWithCal 3 жыл бұрын
Your welcome, thanks for the support.
@cassiomendes5123
@cassiomendes5123 2 жыл бұрын
I tried to add a backspace button there but isn´t working correctly. When I delete something and I put a new number, the number that I´d deleted is showing up again. What can i do?
@subhajeetchakraborty1791
@subhajeetchakraborty1791 2 жыл бұрын
Best tutorial to be honest
@saifullahrahman
@saifullahrahman 3 жыл бұрын
why do you not use the constraint layout method?
@CodeWithCal
@CodeWithCal 3 жыл бұрын
I think it depends what your building. I have nothing against constraint layouts. But i feel like for this application it was easier to use Linear Layout.
@legend.Is.a.qt.WasTaken
@legend.Is.a.qt.WasTaken 3 жыл бұрын
bless up am in class doing a quiz then this saved me bless up bless up
@sheriffcrandy
@sheriffcrandy 2 жыл бұрын
say bless up again
@legend.Is.a.qt.WasTaken
@legend.Is.a.qt.WasTaken 2 жыл бұрын
@@sheriffcrandy bless up
@markjohnpaulmonton5318
@markjohnpaulmonton5318 Жыл бұрын
Thank you
@charleslandercanillas1213
@charleslandercanillas1213 2 жыл бұрын
Bro. Can I ask? Why is ScriptEngine and ScriptEngineManager not working on me? It says that it cannot resolve symbole 'ScriptEngine' and 'ScriptEngineManager'. Thanks bro
@charleslandercanillas1213
@charleslandercanillas1213 2 жыл бұрын
Anyway I found it. I just needed to Sync project with gradle files.
@nics.nvrlnd
@nics.nvrlnd 2 жыл бұрын
hey sir, you're quite good, pls create a tutorial for publishing an android app, connecting android app to database(sqlite) etc. thanks! ♡
@CodeWithCal
@CodeWithCal 2 жыл бұрын
Publishing app tutorial is a good idea. Sqlite database tutorial: kzfaq.info/get/bejne/atFhjbChtJ--nmQ.html
@nics.nvrlnd
@nics.nvrlnd 2 жыл бұрын
@@CodeWithCal thank you idol ♡
@abdallahomar5205
@abdallahomar5205 3 жыл бұрын
Very good tutorial thank you a lot ❤️ But i have a little comment , you have an error in ^ it is not working well if you get a power of a number which has more than a digit like 10^2 because when you get the left number in changeFormula() the number will be 01 instead of 10 so it will get the power of 01^2 instead of 10^2
@CodeWithCal
@CodeWithCal 3 жыл бұрын
Good eye, Thanks for sharing. For a quick fix, underneath our loop which we create our number left we could use a string builder reverse our numberLeft String. StringBuilder leftNumberBuilder = new StringBuilder(numberLeft); numberLeft = leftNumberBuilder.reverse().toString(); stackoverflow.com/questions/7569335/reverse-a-string-in-java
@asadbekaminboyev3311
@asadbekaminboyev3311 2 жыл бұрын
good job bro
@burakozcan1001
@burakozcan1001 2 жыл бұрын
teşekkür ederijm
@shiamahamedluvon117
@shiamahamedluvon117 3 жыл бұрын
Go a head bro.. Best of luck.
@krishnagawali1955
@krishnagawali1955 2 жыл бұрын
Problem in initTextviews method plz help
@charleslandercanillas1213
@charleslandercanillas1213 2 жыл бұрын
I just realize this program doesn't have a delete button, where you can delete one character at a time.
@CodeWithCal
@CodeWithCal 2 жыл бұрын
Take a look at this kotlin calculator app tutorial, we implement a backspace button in this calculator :) kzfaq.info/get/bejne/aM6De8qm082ze30.html
@frankappiah2090
@frankappiah2090 Жыл бұрын
my texts are automatically left aligned, how can that be fixed?
@benabdallahanwer1045
@benabdallahanwer1045 3 жыл бұрын
the message of toast doesn't show up ? any solution
@CodeWithCal
@CodeWithCal 3 жыл бұрын
Design is to show toast message if the input is invalid. could your input simply be valid? Failing that. does your toast message show if you move the Toast line outside of the try catch statement? Toast.makeText(this, "TestToast", Toast.LENGTH_SHORT).show(); try { result = (double)engine.eval(formula); } catch (ScriptException e) { Toast.makeText(this, "Invalid Input", Toast.LENGTH_SHORT).show(); }
@asadbekaminboyev3311
@asadbekaminboyev3311 2 жыл бұрын
lets go
@mrmaroko193
@mrmaroko193 2 жыл бұрын
After click on equal button when both TextViews are empty app crashing, i dont know where is the problem pls help
@mrmaroko193
@mrmaroko193 2 жыл бұрын
I solved it, just added if (workings.equals("") || resultsTV.equals("")) { Toast.makeText(this, "Empty Fields", Toast.LENGTH_SHORT).show(); return;
@kartikhegadi7574
@kartikhegadi7574 Жыл бұрын
After pressing' =' the answer displays. The press something without clearing old answer . It will continue in same place.
@tafman
@tafman 2 жыл бұрын
This is an amazing tutorial.... I was following the tutorial smoothly until you reached the ScriptEngine coding... My problem is 'ScriptEngine', 'shortName 'and 'eval'... They are all showing red lines.... When i checked the hint it shows the following: import class Create class Create enum... etc Please what am i doing wrong... I'll have to pause the calculator for now... Will be waiting for your reply.... Thanks in advance...
@CodeWithCal
@CodeWithCal 2 жыл бұрын
06:25 make sure you have correctly added the dependency in the Build Gradle. :)
@tafman
@tafman 2 жыл бұрын
@@CodeWithCal Thanks for your time, i really appreciate.... Those your dependencies are quite different from mine... Maybe it's because i installed Android Studio recently.... Should i delete my dependencies and input that of yours or i should just add your dependencies to my existing ones?
@CodeWithCal
@CodeWithCal 2 жыл бұрын
Just the one 3rd party line I add is all you should change :)
@luismiguelmanato966
@luismiguelmanato966 2 жыл бұрын
Go to File then click "Sync Project with Gradle Files"
@cemakca6905
@cemakca6905 Жыл бұрын
@@luismiguelmanato966 thanx!
@iamsyndrome5429
@iamsyndrome5429 3 жыл бұрын
Hey I have a problem with Android studio ver4.1 it is not updating the preview .pls help
@CodeWithCal
@CodeWithCal 3 жыл бұрын
Happy to help how I can. Can you provide any more detail?
@gilbertnicholas1062
@gilbertnicholas1062 3 жыл бұрын
@@CodeWithCal I'm having the same problem, the preview in main.xml doesn't update after changed the code in code section of main.xml
@CodeWithCal
@CodeWithCal 3 жыл бұрын
@@gilbertnicholas1062 Hmm 🤔 do you think it is related to using Android studio v4.1? Or could it be a mistake in your Layout XML file?
@kaviyaakavi5969
@kaviyaakavi5969 2 жыл бұрын
I want code for equal without using ScriptEngine.
@CodeWithCal
@CodeWithCal 2 жыл бұрын
kzfaq.info/get/bejne/aM6De8qm082ze30.html This kotlin calculator tutorial uses no external code.
@harshitsolanki1754
@harshitsolanki1754 3 жыл бұрын
Giving Error while I'm using ScriptEngine ? What should I do ..??
@CodeWithCal
@CodeWithCal 3 жыл бұрын
Hi, happy to help. What error are you getting?
@RinitaJ
@RinitaJ 3 жыл бұрын
I got the same error too
@CodeWithCal
@CodeWithCal 3 жыл бұрын
@joshua kregg I think you are spot on here. Thanks for clarifying for all :)
@coderdemo9169
@coderdemo9169 3 жыл бұрын
Can I use c language in the place of java hete
@CodeWithCal
@CodeWithCal 3 жыл бұрын
developer.android.com/studio/projects/add-native-code Maybe, I haven't had any experience doing so.
@RaiMuhammadArslan786
@RaiMuhammadArslan786 3 жыл бұрын
you can make android apps on visual studio with c++
@guruprasad.r766
@guruprasad.r766 3 жыл бұрын
I have a doubt, (3:08) for me when I copy n paste, then the buttons are inserting in the same column
@CodeWithCal
@CodeWithCal 3 жыл бұрын
Check the parent linear layout is correct and it's orientation is set to vertical
@kaiden7866
@kaiden7866 2 жыл бұрын
how can i make calculator but the result will display in other activities
@CodeWithCal
@CodeWithCal 2 жыл бұрын
One way is to pass the result via an intent
@vipulsingh4893
@vipulsingh4893 Жыл бұрын
Bro please give the code that u have written in this video
@CodeWithCal
@CodeWithCal Жыл бұрын
Link in the description 👆
@kalelda3295
@kalelda3295 2 жыл бұрын
How to download the javascript
@CodeWithCal
@CodeWithCal 2 жыл бұрын
I think its available on the web just search the package name
@audday6
@audday6 3 жыл бұрын
i cant enable script engine why? theres no class for it
@CodeWithCal
@CodeWithCal 3 жыл бұрын
06:25 make sure you have correctly added the dependency in the Build Gradle. :)
@ArianKapllanaj
@ArianKapllanaj 3 жыл бұрын
@@CodeWithCal I add everything exactly like you and still, I have a red underline
@CodeWithCal
@CodeWithCal 3 жыл бұрын
And the build Gradle managed to sync with the added dependancy no errors?
@ArianKapllanaj
@ArianKapllanaj 3 жыл бұрын
@@CodeWithCal I do not have any error in build.gradle, I have red text in actibity_main.xml in the words: ScriptEngine, ScriptEngineManager, shortName, and eval.
@ArianKapllanaj
@ArianKapllanaj 3 жыл бұрын
@@CodeWithCal Now I did sync and it works. But shortName was red again and I change the code as it is in GitHub ScriptEngine engine = new ScriptEngineManager().getEngineByName("rhino");
@neferiusnexus2607
@neferiusnexus2607 3 жыл бұрын
your voice sounds fine in the beginning but it's painfully sibilant when you go into coding
@CodeWithCal
@CodeWithCal 3 жыл бұрын
Thanks for the feedback, yes I didn't quite have my mic 🎤 situation sorted at this point.
@pritidwivedi5021
@pritidwivedi5021 2 жыл бұрын
@@CodeWithCal you are writing like a express train plss
@javatmz
@javatmz 3 жыл бұрын
hello can we make a video in partnership?
@CodeWithCal
@CodeWithCal 3 жыл бұрын
Hi, what do you have in mind?
@javatmz
@javatmz 3 жыл бұрын
@@CodeWithCal we can make tutorial in twice or other things as you want
@merajhotak7330
@merajhotak7330 2 жыл бұрын
thanks for project but you maked too faster and cant make sense very well
@KTones
@KTones 3 жыл бұрын
Leyyaok
@shamsnadeem3308
@shamsnadeem3308 3 жыл бұрын
very fast
@CodeWithCal
@CodeWithCal 3 жыл бұрын
💨
@supreme7719
@supreme7719 3 жыл бұрын
@@CodeWithCal hahaa
@candrasniper3404
@candrasniper3404 Жыл бұрын
The implementation... is the key to make it easy. I had built the calc with my own code, but it was getting frustating sometimes with the math result, related to double floating point in accuracy. Sometimes, it should be 1.1, but it was showed 1.09999999998. 😅
@CodeWithCal
@CodeWithCal Жыл бұрын
kzfaq.info/get/bejne/hsCCfJR6y7nYiWQ.html Tom Scott did a great video on this very topic
Calculator App Android Studio Kotlin Tutorial
12:22
Code With Cal
Рет қаралды 72 М.
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 536 М.
ОСКАР ИСПОРТИЛ ДЖОНИ ЖИЗНЬ 😢 @lenta_com
01:01
Build this JS calculator in 15 minutes! 🖩
15:20
Bro Code
Рет қаралды 417 М.
How to make a calculator in Android Studio 2020 | Part 3
23:19
Practical Coding
Рет қаралды 68 М.
All useEffect Mistakes Every Junior React Developer Makes
22:23
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 461 М.
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 536 М.