}
}
fun restart(){
count=0
setQuestions()
trueanswer=0
falseanswer=0
binding.apply {
// linearlay1.visible()
// pieChart.gone()
textviewnext.text="next"
// textviewtrueorfalseanswer.gone()
}
}
fun checkanswers(questionModel: QuestionModel,view: TextView, layout: RelativeLayout){
binding.apply {
if (view.text.toString()==questionModel.answer){
//showtoast(this@MainActivity,"true")
ltAnimationRigt.visibility= View.VISIBLE
ltAnimationRigt.playAnimation()
checkcolor(true,view,layout)
if (cheked){
ltAnimationRigt.visibility= View.GONE
ltAnimationRigt.cancelAnimation()
trueanswer++
cheked=false
}
}else{
//showtoast(this@MainActivity,"false")
ltAnimationWrong.visibility = View.VISIBLE
ltAnimationWrong.playAnimation()
checkcolor(false,view,layout)
if (cheked){
ltAnimationWrong.visibility = View.GONE
ltAnimationWrong.cancelAnimation()
cheked=false
falseanswer++
}
}
}
}
fun checkcolor(trueorfalse:Boolean,view: TextView, layout: RelativeLayout){
if (trueorfalse){
view.background= ContextCompat.getDrawable(this@MainActivity6Test,R.drawable.background_green)
layout.background = getDrawable(R.drawable.background_green)
}else{
view.background=ContextCompat.getDrawable(this@MainActivity6Test,R.drawable.background_red)
layout.background = getDrawable(R.drawable.background_red)
}
}
fun clearcheckcolor(){
binding.apply {
textviewanswer1.background=ContextCompat.getDrawable(this@MainActivity6Test,R.drawable.bg_ansverrelative)
relAnswer1.background=ContextCompat.getDrawable(this@MainActivity6Test,R.drawable.bg_ansverrelative)
textviewanswer2.background=ContextCompat.getDrawable(this@MainActivity6Test,R.drawable.bg_ansverrelative)
relAnswer2.background=ContextCompat.getDrawable(this@MainActivity6Test,R.drawable.bg_ansverrelative)
textviewanswer3.background=ContextCompat.getDrawable(this@MainActivity6Test,R.drawable.bg_ansverrelative)
relAnswer3.background=ContextCompat.getDrawable(this@MainActivity6Test,R.drawable.bg_ansverrelative)
textviewanswer4.background=ContextCompat.getDrawable(this@MainActivity6Test,R.drawable.bg_ansverrelative)
reAnswer4.background=ContextCompat.getDrawable(this@MainActivity6Test,R.drawable.bg_ansverrelative)
Dostları ilə paylaş: |