Issue
Sorry I am a bit new to stack overflow but hopefully the question is understandable!
I talked to a staff memeber/community member who showed me Intent to go from 1 activity(in my case GlobeActivity where my animation is stored) to another activity( MainActivity where username/password is stored). But the animation does not show up, instead it cuts directly to MainActivity.
Anyone got some suggestions to why and how to make it so that when animation is finished, it re-directs/ transitions to MainActivity without use of buttons?
Here is my code so far:
GlobeActivity( my SecondActivity):
package com.example.testerino2022
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
class GlobeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_globe)
supportActionBar?.hide()
val textView = findViewById<TextView>(R.id.textGlobeScreen)
textView.animate().translationX(1050F).setDuration(1000).setStartDelay(2500)
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
finish()
}
}
MainActivity(has default code in it );
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
Solution
textView.animate()
.translationX(1050F)
.setDuration(1000)
.setStartDelay(2500)
.withEndAction {
startActivity(Intent(context, MainActivity::class.java))
finish()
}
Answered By - Ömer Seyfettin Yavuzyiğit
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.