Bonjour,
j’aimerais savoir si vous avez le même problème que moi?
Je suis les cours sur kotlin android studio. Tout se passe bien quand je suis les cours kotlin, quand tout est simple, par exemple: p1, p2, p3 héritent des fonctions de la classe personnage, c’est assez simple à comprendre. mais dès qu’on arrive sur android studio pour la création d’une application, je commence à être largué. je n’arrive même plus à savoir quand la notion d’héritage intervient…
par exemple dans ce code:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_third)
}
override fun onResume() {
super.onResume()
startSlideShow()
}
val photoList = arrayOf(R.drawable.A, R.drawable.B, R.drawable.C, R.drawable.D, R.drawable.E)
var currentPhotoIndex = 0
var countDownTimer:CountDownTimer? = null
fun nextButtonTouched(button:View){
stopSlideShow()
showNextPhoto()
startSlideShow()
}
fun stopSlideShow() {
countDownTimer?.cancel()
countDownTimer = null
}
fun previousButtonTouched(button:View){
stopSlideShow()
currentPhotoIndex = currentPhotoIndex - 1
if(currentPhotoIndex < 0){
currentPhotoIndex = photoList.size - 1
}
imageView.setImageResource(photoList[currentPhotoIndex])
startSlideShow()
}
fun startSlideShow(){
countDownTimer = object:CountDownTimer(3000,3000) {
override fun onFinish() {
showNextPhoto()
startSlideShow()
}
override fun onTick(millisUntilFinished: Long) {}
}
countDownTimer?.start()
}
fun showNextPhoto(){
currentPhotoIndex = currentPhotoIndex + 1
if(currentPhotoIndex >= photoList.size){
currentPhotoIndex = 0
}
imageView.setImageResource(photoList[currentPhotoIndex])
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState?.putInt("currentPhotoIndex",currentPhotoIndex)
}
override fun onRestoreInstanceState(savedInstanceState: Bundle?) {
super.onRestoreInstanceState(savedInstanceState)
currentPhotoIndex = savedInstanceState?.getInt("currentPhotoIndex") ?: 0
imageView.setImageResource(photoList[currentPhotoIndex])
}
}
où est ce qu’on parle d’héritage?
j’ai l’impression que c’est vraiment compliqué quand je fais la transition des simples cours avec des personnages vers les cours d’applications avec les termes techniques d’android studio.