Android / Kotlin -Adding Two Numbers using EditText

  Рет қаралды 14,312

Vlad Voytenko

Vlad Voytenko

Күн бұрын

Пікірлер
@VladVoytenko
@VladVoytenko 3 жыл бұрын
Note: @6:25 time : You need to use findViewById() to access the button ID from resource file @7:03 time : You need to use findViewById() to access the textResult ID, editNum1, editNum2 from resource file
@monsterscaveff7634
@monsterscaveff7634 2 жыл бұрын
from where?
@VladVoytenko
@VladVoytenko 2 жыл бұрын
@@monsterscaveff7634 at time frames: 6:25, 7:03
@subhadeepmukherjee3527
@subhadeepmukherjee3527 4 жыл бұрын
@Vlad Voytenko Sir, will you make a video on how to check odd even number in kotlin? or can you give me the java/kotlin code for the main activity?Please
@supxjavi2831
@supxjavi2831 3 жыл бұрын
I am trying to make a small profit calculator using this video as an idea. What would I do for the code if I wanted to subtract editNum2 from editNum1 (Sold Price-Item Cost = Profit)
@mohammedelaminetellai7569
@mohammedelaminetellai7569 2 жыл бұрын
thank you but I have a problem button it's not identified in kt file
@VladVoytenko
@VladVoytenko 2 жыл бұрын
check my comments under the video - it may help
@anurajms
@anurajms 3 жыл бұрын
thank you this was the most helpful video .
@michaelodemena6256
@michaelodemena6256 3 жыл бұрын
as always man a great help has a question though what if I wanted to add decimals together doesn't seem to work as it so just wanted to know what i have to change
@VladVoytenko
@VladVoytenko 3 жыл бұрын
Just instead of Number widget drag and drop Number (Decimal) to your xml.... After that, chamge Kotlin addition operation from int to double. Hope it helps!
@Music-lv8xf
@Music-lv8xf 4 жыл бұрын
how to add two edittext number in textchanged listener?
@VladVoytenko
@VladVoytenko 4 жыл бұрын
A bit old, but using Kotlin Android extensions you can do something like that: editTextRequest.textChangedListener { afterTextChanged { // Do something here... } }
@muteiPod303
@muteiPod303 4 жыл бұрын
Thank you for the helpful video
@VladVoytenko
@VladVoytenko 4 жыл бұрын
You're welcome!
@H.HamzahMD
@H.HamzahMD 5 жыл бұрын
but its crash when no input. how to solve it please. i have try make if (input == null) , but it say null is always false
@VladVoytenko
@VladVoytenko 5 жыл бұрын
you have to check editNum1 and editNum2 before calculation
@AmitKumar-lj4dm
@AmitKumar-lj4dm 5 жыл бұрын
@@VladVoytenko please make another video of that
@raymundoortiz7269
@raymundoortiz7269 4 жыл бұрын
you can use Elvis Operator or something like this: val b: String? = "Kotlin" if (b != null && b.length > 0) { print("String of length ${b.length}") } else { print("Empty string") }
@paryliak
@paryliak 4 жыл бұрын
I am adding the solution that worked for me just in case if anyone else faces the same problem: class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) button.setOnClickListener { if (editNum1.length() > 0 && editNum2.length() > 0) { textResult.text = "Result: " + (editNum1.text.toString().toInt() + editNum2.text.toString().toInt()).toString() Toast.makeText(this, textResult.text, Toast.LENGTH_LONG).show() } else { Toast.makeText(this, "Fill in numbers", Toast.LENGTH_LONG).show() } } } }
@subhadeepmukherjee3527
@subhadeepmukherjee3527 4 жыл бұрын
@@VladVoytenko Sir, will you make a video on how to check odd even number in kotlin? or can you give me the java/kotlin code for the main activity?Please
@reevechaitanya1693
@reevechaitanya1693 3 жыл бұрын
Thanks man
@AyanKhan-it4nl
@AyanKhan-it4nl 4 жыл бұрын
Thanks a lot bro...
@ricardolopez6194
@ricardolopez6194 4 жыл бұрын
ありがとう
@i2911
@i2911 4 жыл бұрын
ありがとう = Arigatau = Thank you
@windschiefhopkins5839
@windschiefhopkins5839 Жыл бұрын
Hi, thanks I just started to learn and this is helpfull! now I am dividing, how would I round the result off to two decimals (dollars.cents) ? I have result.text = number1.text.toString().toDouble() / number2.text.toString().toDouble() cheers
@VladVoytenko
@VladVoytenko Жыл бұрын
hey, you may use some just Kotlin instrctions to round the number. F.e,. val random = 8435.21057752090819915 val df = DecimalFormat("#.##") df.roundingMode = RoundingMode.DOWN val roundoff = df.format(random) println(roundoff) // 8435.21
@windschiefhopkins5839
@windschiefhopkins5839 Жыл бұрын
@@VladVoytenko hm, doesnt seem to work. I just don't know enough to get ahead - probably need in-person schooling lol , so how to round my result.text which is defined in MainAcitivity.kt and printed in a TextView area in activity_main.xml sorry, don't need to answer, obviously I am lacking some basics....
Pass Data to the next Activity using Intent (Kotlin) - Android Studio
19:13
How to Add  Two Numbers  using  Android  Kotlin
15:50
Tutus Funny
Рет қаралды 8 М.
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
Android Tutorial (Kotlin) - 11 - EditText
7:45
CodeAndroid
Рет қаралды 12 М.
Pass Data between Activities using intent | Android Studio | Kotlin
14:18
Learn Kotlin in 12 Minutes
12:01
Rahul Pandey
Рет қаралды 345 М.
INTENTS AND STARTING ACTIVITIES - Android Fundamentals
16:11
Philipp Lackner
Рет қаралды 70 М.
How to use Radio Buttons and Radio Groups - Android Kotlin
11:55
Vlad Voytenko
Рет қаралды 14 М.
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН