Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. Kotlin Interface Listener inheritance Error

Kotlin Interface Listener inheritance Error

Scheduled Pinned Locked Moved Android
androidjavacomoophelp
4 Posts 4 Posters 13 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leesungyoen
    wrote on last edited by
    #1

    package com.ishidakorea.test02

    import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import java.lang.Exception

    class MainActivity : AppCompatActivity(), A.interA, Child.interChild
    {
    override fun Child_EventFire()
    {
    // Child Class Listener
    }
    override fun A_SendPost()
    {
    // AA Class Listener
    }

    override fun onCreate(savedInstanceState: Bundle?)
    {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity\_main)
    
        var A1 = A()
    
    }
    

    }

    class A : Child(), Child.interChild {

    interface interA
    {
        fun A\_SendPost()
    }
    
    lateinit var LinstenerA : A.interA
    
    init {
        LinstenerA = this@A as A.interA // Exception
    }
    
    fun FireA()
    {
        if (LinstenerA != null)
            LinstenerA.A\_SendPost()
    }
    
    override fun Child\_EventFire()
    {
    
    }
    

    }

    open class Child {

    interface interChild
    {
        fun Child\_EventFire()
    }
    
    lateinit var LinstenerB : interChild
    
    init {
            LinstenerB = this@Child as interChild // OK
    }
    
    fun Fire()
    {
        if (LinstenerB != null)
            LinstenerB.Child\_EventFire()
    }
    

    }

    An error occurs while creating a new listener from a parent class that inherits a child class that has a listener.

    Why is that?

    If you know anyone, please advise.

    L S D 3 Replies Last reply
    0
    • L leesungyoen

      package com.ishidakorea.test02

      import androidx.appcompat.app.AppCompatActivity
      import android.os.Bundle
      import java.lang.Exception

      class MainActivity : AppCompatActivity(), A.interA, Child.interChild
      {
      override fun Child_EventFire()
      {
      // Child Class Listener
      }
      override fun A_SendPost()
      {
      // AA Class Listener
      }

      override fun onCreate(savedInstanceState: Bundle?)
      {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity\_main)
      
          var A1 = A()
      
      }
      

      }

      class A : Child(), Child.interChild {

      interface interA
      {
          fun A\_SendPost()
      }
      
      lateinit var LinstenerA : A.interA
      
      init {
          LinstenerA = this@A as A.interA // Exception
      }
      
      fun FireA()
      {
          if (LinstenerA != null)
              LinstenerA.A\_SendPost()
      }
      
      override fun Child\_EventFire()
      {
      
      }
      

      }

      open class Child {

      interface interChild
      {
          fun Child\_EventFire()
      }
      
      lateinit var LinstenerB : interChild
      
      init {
              LinstenerB = this@Child as interChild // OK
      }
      
      fun Fire()
      {
          if (LinstenerB != null)
              LinstenerB.Child\_EventFire()
      }
      

      }

      An error occurs while creating a new listener from a parent class that inherits a child class that has a listener.

      Why is that?

      If you know anyone, please advise.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      leesungyoen wrote:

      An error occurs

      What error, and where does it occur?

      1 Reply Last reply
      0
      • L leesungyoen

        package com.ishidakorea.test02

        import androidx.appcompat.app.AppCompatActivity
        import android.os.Bundle
        import java.lang.Exception

        class MainActivity : AppCompatActivity(), A.interA, Child.interChild
        {
        override fun Child_EventFire()
        {
        // Child Class Listener
        }
        override fun A_SendPost()
        {
        // AA Class Listener
        }

        override fun onCreate(savedInstanceState: Bundle?)
        {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity\_main)
        
            var A1 = A()
        
        }
        

        }

        class A : Child(), Child.interChild {

        interface interA
        {
            fun A\_SendPost()
        }
        
        lateinit var LinstenerA : A.interA
        
        init {
            LinstenerA = this@A as A.interA // Exception
        }
        
        fun FireA()
        {
            if (LinstenerA != null)
                LinstenerA.A\_SendPost()
        }
        
        override fun Child\_EventFire()
        {
        
        }
        

        }

        open class Child {

        interface interChild
        {
            fun Child\_EventFire()
        }
        
        lateinit var LinstenerB : interChild
        
        init {
                LinstenerB = this@Child as interChild // OK
        }
        
        fun Fire()
        {
            if (LinstenerB != null)
                LinstenerB.Child\_EventFire()
        }
        

        }

        An error occurs while creating a new listener from a parent class that inherits a child class that has a listener.

        Why is that?

        If you know anyone, please advise.

        S Offline
        S Offline
        SeanChupas
        wrote on last edited by
        #3

        leesungyoen wrote:

        Why is that? If you know anyone, please advise.

        Since there are 143,213,227 possible errors, I don't think we should guess. It would help if you would post the actual error message.

        1 Reply Last reply
        0
        • L leesungyoen

          package com.ishidakorea.test02

          import androidx.appcompat.app.AppCompatActivity
          import android.os.Bundle
          import java.lang.Exception

          class MainActivity : AppCompatActivity(), A.interA, Child.interChild
          {
          override fun Child_EventFire()
          {
          // Child Class Listener
          }
          override fun A_SendPost()
          {
          // AA Class Listener
          }

          override fun onCreate(savedInstanceState: Bundle?)
          {
              super.onCreate(savedInstanceState)
              setContentView(R.layout.activity\_main)
          
              var A1 = A()
          
          }
          

          }

          class A : Child(), Child.interChild {

          interface interA
          {
              fun A\_SendPost()
          }
          
          lateinit var LinstenerA : A.interA
          
          init {
              LinstenerA = this@A as A.interA // Exception
          }
          
          fun FireA()
          {
              if (LinstenerA != null)
                  LinstenerA.A\_SendPost()
          }
          
          override fun Child\_EventFire()
          {
          
          }
          

          }

          open class Child {

          interface interChild
          {
              fun Child\_EventFire()
          }
          
          lateinit var LinstenerB : interChild
          
          init {
                  LinstenerB = this@Child as interChild // OK
          }
          
          fun Fire()
          {
              if (LinstenerB != null)
                  LinstenerB.Child\_EventFire()
          }
          

          }

          An error occurs while creating a new listener from a parent class that inherits a child class that has a listener.

          Why is that?

          If you know anyone, please advise.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Does the message appear during compilation or execution? If the latter, should you be using try/catch blocks to help trap the error?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups