-2

Hey, I am looking to make a android app, but i got a sh!t ton of errors. I am new to Kotlin and dont know anything about these errors. Here is the code:

package com.farder.inc.zortosinstaller

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button

button = b
Imageview img
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        b= (Button) findViewById(R.id.button)
        img = (ImageView) findViewById(R.id.imageView)
        b.setOnClickListener(View.OnClickListener {
            @Override
            public void onClick(View v) {
                img.set.ImageResource(R.mipmap.amogus)
            }
            )
    }
}

Please Help!

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jul 29 '22 at 02:36
  • There's a lot going on here, for example you're mixing Java code inside a Kotlin file (`@Override ...`). I recommend looking up some tutorials for absolute beginners to Kotlin for Android rather than posting a chunk of code and hoping someone will fix it. – Can_of_awe Jul 29 '22 at 07:46
  • well all the beginner videos use java but.. ill try! or maybe ill just swich to java – Funey95 Jul 29 '22 at 10:03

1 Answers1

1

Firstly you should move these 2 lines to be inside the main class

button = b
Imageview img // and change Imageview to ImageView

This line doesn't do what you want it to img.set.ImageResource(R.mipmap.amogus) This question and answers will help you with that Changing ImageView source

After that, if you still have errors you should post a new question and state what they are

Ivan Wooll
  • 4,145
  • 3
  • 23
  • 34
  • Umm.... what is a "Main class"? And thats how you know i am a beginner ;) – Funey95 Jul 28 '22 at 20:30
  • The main class starts with this line. 'class MainActivity : AppCompatActivity() {'. If you move those 2 lines directly below that you will be inside the main (and only) class – Ivan Wooll Jul 28 '22 at 20:41
  • i did it and holy macaroni, i had 21 errors and now there are 28! 5 errors are saying execpting member declaration and some other errors that i cant find. maybe thaey are new expecting a new top member declaration error (there are 5 of them). – Funey95 Jul 28 '22 at 20:47