想要在单击按钮时转到下一张图像,但应用程序不断崩溃

时间:2019-06-18 14:42:37

标签: android kotlin imageview

MainActivity类:AppCompatActivity(){

var ind1 = 0;
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
  var im1:ImageView=findViewById(R.id.im1) as ImageView
  var im2:ImageView=findViewById(R.id.im2) as ImageView
    b1.setOnClickListener()
    {
        if (ind1 == 0) {
        im1.setImageResource(R.drawable.int1)
        im2.setImageResource(R.drawable.i1)
        } 
        else if (ind1 == 1) { 
            im1.setImageResource(R.drawable.int2)
            im2.setImageResource(R.drawable.i2)
            welcome.text=""
            scroll.text = "-=--"
            data.text = "Generate Random Teams To Make It More Interesting!"
        } 
        else if (ind1 == 2) {
            im1.setImageResource(R.drawable.int3)
            im2.setImageResource(R.drawable.i3)

            scroll.text = "--=-"
            data.text = "Choose From Knockouts,Leagues Or Hybrid Tournaments!"
        } else if (ind1 == 3) {
            im1.setImageResource(R.drawable.int4)
            im2.setImageResource(R.drawable.i4)

            scroll.text = "---="
            data.text = "Have Fun And Enjoy!!"
            b1.text = "LETS GO"

        }
        ind1++


    }
}

}

还尝试制作一个intarrayof并将其放入其中,但该应用程序仍然崩溃,并且没有给出任何错误,而且即使没有更改该应用程序的图像视图也能正常工作

0 个答案:

没有答案