androidkotlinandroid-studio

How to get the "view" when it comes to OnClickListener for Android Studios?


Very basic Android Studio question:

How do I activate that Toast?

Normally, if I type in anything in Android Studio, I get a list of code I can Alt+Enter on / click on and it implements it. How do I implement that in the attached picture? so it looks like this:

I clicked the buttons that normally would implement stuff like Alt+Enter but that doesn't seem to be working. How do I get that second image from that first image?

Edit: I found a good example of what i mean: check out this youtube:> https://www.youtube.com/watch?v=OP0tK5FAMn8 <: at the "15min and 21secont TO 22second mark" you'll see what i mean. after homeboy puts down the code, it 'goes into the second picture.' it plugs in "it:View". BUT WHEN IIIIIIIII DOOOO IIIITTTTT!? i get the "First picture". a toast asking me if i want to plug in the "it view" thing. and im saying: "YES! I WANT THAT!" and im here on stackoverflow asking: "How do i get to that second picture? im not getting that. Im getting to the first picture. Id like the "it:view" that the system plugs in. do i have to click something for that? cause i normally do alt+enter- and that's not working. This is my question"

Second Edit:

Some have suggested i press enter, and then paste the code; or to just press enter, and that it will show up on its. its not. here's the attached image of it not showing up on its own: attaches another image its still missing the "it:view"

My question revolves how to get that "it:View!" on there. the pressing of enter after the brackets is not implementing it on its own. Im sorry for sharing what im sharing but im really thankful for all the help. We are targetting the right question tho

Third Edit & Potential Answer:

Thank you to @Computable for sharing this attaches response of a potential solution using ctrl+space

WHEN I DID @COMPUTABLE 'S RESPONSE of CTRL+Space (Which, btw, i loved. its amazing.) i found myself looking at:> this attached image and i pressed the one with the green arrow (i pressed the one with the green arrow, cause i couldnt find the dot dot dot one that computable mentioned).

Am i clicking on the right one? cause i got this code/image in response:> AND IT LOOKS RIGHT!? But is that my inexperience talking? cause im trying to get "it: View" but this one says, essentially???? the same thing???? Maybe thats my inexperience talking cause "essentially the same thing" and "the same thing" are not "the:> same <:thing" and i dont wanna move on from this saying: "GOOD ENOUGH!" if its not even "the:> same <:thing" you know?

Fo realsie- yall helping me are beautiful. i just wanna know how to activate that toast to get "it: View" and fr fr: "Ctrl+space" is a beautiful thing to learn- even tho that wasnt what i was going for hahaha

My main question is still:> "how to get the "it:View" found in the second image, from the first image. @Computable 's response, got me to a potential answer. But my inexperience is leading me to ask:> "are those two the same thing?" or would i still have to do something else to get to "it: View"?

Fourth & Final Edit including: WE FOUND THE ANSWER! (& Closing Conclusion of how we got there:)

MY FELLOW STACKOVERFLOWIANS! WE DID IT! WE TURNED IT INTO IT VIEW! LOOK: attaches image THAT'S MY IT VIEW! THAT'S MINE!!! WOOT WOOOOOOOT!!!!!

I would like to thank both: @NguyễnMạnhCường / @Nguyễn Mạnh Cường (idk how to tag you properly but you have a cool *** name & i love you for helping me from across the world like that. i love you Nguyễn Mạnh Cường) for sharing with me that "WHAT IIIIIIII WAS LOOKING AT! Was a "Settings" thang. Cool. Didnt know that. Homebrah told me: "Go to yo settings/editor/inlay hints" then: "Check lambdas" (And y'all are not gonna believe this but: "LAMBDAS!? WAS THE OOOOOOONLY ONE NOT TURNED ON!!!" and good lohd. when i clicked that on? Boomchakalakababywhatsup. We got to our answer. thas' MY, IT VIEW! i didnt know how to properly ask the question. but i knew how to point to it and go: "THAT! HOW DO I GET THAT!? I WANT THAT!" and Nguyễn Mạnh Cường came along and gave not only the answer i was looking for; but also explained that: "it:View" is a "hint" generated by the IDE then told me how to turn it on and off. i didnt know that folks. i didnt know what to ask but i knew what to point to; and so many of you came and helped me out so wonderfully. and now that i got to my answer im like: "YEP! LOOK AT LIL OL NEWBIE ME ASKING WHERE'S THE "TURN ON HINT BOX" AND NOT KNOWING IT WAS CALLED: "Lambda"" hahahahahahahahah LOVE IT! SO MANY OF YOU CAME AND HELPED ME! So many of you came and gave me different pieces of advice from: @NguyễnMạnhCường @Lule (Who gave the same (but more detailed) advice- but i saw Nguyen's first- and tested theirs out- AND SO THANK YOU! YOU EVEN GAVE DETAILED PICS! YOU A G @LULE !) @tyczj for being so patient with me and sharing with me solutions on how to get to where im going but my stubborn self was trying to find the hint box without knowing i was asking for the hint box to be turned on hahahahaha @Computable for teaching me about ctrl+space ! You're a G

And a def "No, Thank You" to the ppl editing my text and removing the american flavor in my language. "Your mother never loved you- and it's because you do stuff like this" <3.

Have a great life everyone! Thank you for helping me out on this adventure and I wish all your dreams come true!!!


Solution

  • I have to tell you this. "it:View" is a "hint" generated by the IDE. It helps you understand that in this lambda there is a variable named it, type View. You can even rename this variable by specifying the name as in the following example:

    binding.password.setOnClickListener{viewPassword: View -> }
    

    Or

    binding.password.setOnClickListener{viewPassword -> }
    

    If you don't specify its name, the IDE will always automatically assume that the variable is named "it".

    So, Even if "it:View" is not visible(Maybe some IDE settings turned it off). But you can still use it.

    Update: I found a way to make the IDE always show this hint. First go to Settings/Editor/inlay Hints. Check Lambdas And click OK. Now that hint will always be visible and you will see "it:View" as you want.