Results 1 to 2 of 2
  1. #1
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    286
    Rep Power
    6

    Default Basic question on When a class extends a class and implements an interface

    I have a class which extends a class and implements an interface. Within the class, I am trying to invoke a method which expects an object of the extended class as the first argument, but when I do so, I get the compiler error that "The constructor Intent(MainActivity.DrawerItemClickListener, Class<MyPreferencesActivity>) is undefined".

    Java Code:
    public class MainActivity extends FragmentActivity implements DrawerLayout.DrawerListener {
        ...
            Intent intent = new Intent(this, MyPreferenceActivity.class); //*****error***
        ...
    }
    This tells me the implemented interface is getting precedence over the extended class, but I want to call this constructor ofcourse.

    So the question is that is there a way to change this behavior, that is to force (an object of the) MainActivity class to consider itself an instance of FragmentActivity, before considering itself an DrawerLayout.DrawerListener?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Basic question on When a class extends a class and implements an interface

    I think you neglected to mention or show that the uncompilable line is inside an inner class.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 07-08-2012, 05:23 PM
  2. Replies: 4
    Last Post: 01-17-2012, 12:39 AM
  3. What about variables? implements Interface > extends
    By Bigfatcat in forum New To Java
    Replies: 8
    Last Post: 01-08-2012, 08:57 AM
  4. Extends a class that implements an interface
    By monocole in forum New To Java
    Replies: 2
    Last Post: 12-27-2011, 03:55 AM
  5. Basic Class Interaction Question
    By McChill in forum New To Java
    Replies: 1
    Last Post: 05-09-2009, 11:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •