3

I have a an android java class which I am extends another activity , however I would also like to include my ActionbarActivity as well. The code I have below does not seem to do the trick.

public class ExpandableListMainActivity extends ExpandableListActivity   implements ActionBarActivity  
Zidane
  • 1,696
  • 3
  • 21
  • 35
  • 3
    Make ExpandableListMainActivity extend AppCompatActivity. It's not an interface, and Java doesn't have multiple inheritance. – Daniel Nugent Jan 19 '16 at 08:03

2 Answers2

0

First of all, ActionBarActivity is deprecated.You should use AppCompatActivity instead.

Why was ActionBarActivity deprecated

Secondly, extends ExpandableListActivity implements ActionBarActivity won't work.

Use it like this instead :

public class ExpandableListMainActivity extends AppCompatActivity

For reasons: Implements vs extends: When to use? What's the difference?

  • implements is for implementing an interface

    extends is for extending a class.

So, that's not an interface.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
0

Your Activity should extends AppCompactActivity and then you should declare an ExpandableListView in XML layout for the Activity.

In onCreate of the Activity : setContentView(that_xml_file);

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ExpandableListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </ExpandableListView>

</RelativeLayout>
frogatto
  • 28,539
  • 11
  • 83
  • 129