1. Are you ready for the Galaxy S20? Here is everything we know so far!

How to override onCreate method in kotlin in android studio

Discussion in 'Android Development' started by neha goenka, Dec 4, 2021.

  1. neha goenka

    neha goenka Lurker
    Thread Starter

    Hello I am making a app in which when main activity opens a lotte animation plays as a button and when i click on that animation (button) then activity 2 opens and plays a video and when the video get completes i called main activity again using intent, so when main activity opens again i want that now that animation button hides.

    I tried to write override onresume and i also tried override onrestart and then i wrote

    override fun onRestart() {
    super.onRestart()
    binding.btnanimation.visibility = View.INVISIBLE
    }

    but when i do that then when activity opens in starting then also that button animation get hides, but i want that when app opens it must be visible as its called inside oncreate

    my onCreate code something like this

    override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    binding = ActivityMainBinding.inflate(layoutInflater)

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN)


    setContentView(binding.root)


    binding.btnanimation.visibility = View.VISIBLE

    So what mistake i am doing and how to fix that ?
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...