skip to Main Content

Hello Developers , I am trying to build a bottomsheet in android studio by the help of a YouTube video. But in the video the youtuber use kotlin and I don’t know kotlin. I have already complete the layout part but I stucked in the code section.

For the video click here
Or Use this link https://www.youtube.com/watch?v=3vMtHKniOqI&t=250s&ab_channel=DroidUI


bottomsheetbehavior.from(bottomsheet).apply{ 
peekheight=200 
this.state.bottomsheetbehavior.state_collapsed }

3

Answers


  1. In Java it will look something like this:

    BottomSheetBehavior<FrameLayout> behavior = BottomSheetBehavior.from(bottomsheet);
    behavior.setPeekHeight(200);
    behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    
    Login or Signup to reply.
  2. Your question is not clear Actually, what help do you want?
    But as per my understanding, you should search your project on other sources in java if you find, well and good, or else try to know the basic semantics and syntax of kotlin and follow the same resource, code in kotlin & convert into Java.
    .

    Steps to convert kotlin into java:

    Step-1: Open the Kotlin Class/File which is to be converted into Java.

    Step-2: Navigate to Tools Menu

    From the topmost toolbar of the Android Studio, select Tools and then navigate to Kotlin > Show Kotlin Bytecode. It will open a window at the right-hand side that will contain the line by line bytecode for the Kotlin file.
    enter image description here

    Step-3: Decompile Code
    In the bytecode window, checkbox the option “JVM 8 target” and click on Decompile. The Android Studio will generate the Java equivalent code for the Kotlin file.
    enter image description here

    I hope this may be helpful in the last case.

    Login or Signup to reply.
    1. Open your Kotlin project in the IntelliJ IDEA / Android Studio.
    2. Then navigate to Tools > Kotlin > Show Kotlin Bytecode.
    3. You will get the bytecode of your Kotin file.
    4. Now click on the Decompile button to get your Java code from the bytecode.

    https://blog.mindorks.com/how-to-convert-a-kotlin-source-file-to-a-java-source-file

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search