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
@monsterscaveff76342 жыл бұрын
from where?
@VladVoytenko2 жыл бұрын
@@monsterscaveff7634 at time frames: 6:25, 7:03
@subhadeepmukherjee35274 жыл бұрын
@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
@supxjavi28313 жыл бұрын
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)
@mohammedelaminetellai75692 жыл бұрын
thank you but I have a problem button it's not identified in kt file
@VladVoytenko2 жыл бұрын
check my comments under the video - it may help
@anurajms3 жыл бұрын
thank you this was the most helpful video .
@michaelodemena62563 жыл бұрын
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
@VladVoytenko3 жыл бұрын
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-lv8xf4 жыл бұрын
how to add two edittext number in textchanged listener?
@VladVoytenko4 жыл бұрын
A bit old, but using Kotlin Android extensions you can do something like that: editTextRequest.textChangedListener { afterTextChanged { // Do something here... } }
@muteiPod3034 жыл бұрын
Thank you for the helpful video
@VladVoytenko4 жыл бұрын
You're welcome!
@H.HamzahMD5 жыл бұрын
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
@VladVoytenko5 жыл бұрын
you have to check editNum1 and editNum2 before calculation
@AmitKumar-lj4dm5 жыл бұрын
@@VladVoytenko please make another video of that
@raymundoortiz72694 жыл бұрын
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") }
@paryliak4 жыл бұрын
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() } } } }
@subhadeepmukherjee35274 жыл бұрын
@@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
@reevechaitanya16933 жыл бұрын
Thanks man
@AyanKhan-it4nl4 жыл бұрын
Thanks a lot bro...
@ricardolopez61944 жыл бұрын
ありがとう
@i29114 жыл бұрын
ありがとう = Arigatau = Thank you
@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 Жыл бұрын
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 Жыл бұрын
@@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....