title: Use Android ListView from Superclass
body: <p>I'd like to inherit two classes (one of them: "AuthenticateRoomSelectionActivity") from another class ("RoomSelectionBaseActivity"), because I have two activities in an Android app, which are going to be quite similar. They consist of a Constraint Layout, which holds some Buttons, TextViews and (most important) an ListView.</p>
  
  <p>I would like to implement the ArrayAdapter in the Superclass, because the Data-Input is exactly the same. So I implemented a setRoomList() method, which is called back, after some networking is done in another class:</p>
  
  <pre><code>public void setRoomList(Activity activity, ArrayList&lt;Room&gt; roomList) {
      // Save rooms to instance variable
      this.roomList = roomList;
  
      // Populate roomListView
      ArrayAdapter&lt;Room&gt; roomAdapter =
              new ArrayAdapter&lt;&gt;(activity, R.layout.list_row_layout, roomList);
      roomListView.setAdapter(roomAdapter);
  }
  </code></pre>
  
  <p>In the onCreate() method of the inherited class I call the networking method getAllRooms().</p>
  
  <pre><code>// Get all rooms
      RestProvider.getInstance().getAllRooms(this);
  </code></pre>
  
  <p>The RestProvider-method collects network data with Retrofit 2:</p>
  
  <pre><code>    public void getAllRooms(final RoomSelectionBaseActivity activity) {
      Call&lt;ArrayList&lt;Room&gt;&gt; call = mRestAPI.getAllRooms(Session.getInstance().getBearer());
      call.enqueue(new Callback&lt;ArrayList&lt;Room&gt;&gt;() {
  
          // Set room list in activity
          @Override public void onResponse(Call&lt;ArrayList&lt;Room&gt;&gt; call, Response&lt;ArrayList&lt;Room&gt;&gt; response) {
              activity.setRoomList(activity, response.body());
          }
  
          // Show error messages in activity
          @Override public void onFailure(Call&lt;ArrayList&lt;Room&gt;&gt; call, Throwable t) {
              activity.showToast("ERROR: " + t.getMessage());
              Log.v("REST-Error: ", t.getMessage());
          }
      });
  }
  </code></pre>
  
  <p>...and even passes the context's reference to the context, to make sure, it really uses the right context in setRoomList().</p>
  
  <p>I'm totally stuck with this architecture, because there is no ListView shown, when I call AuthenticateRoomSelectionActivity.</p>
  
  <p>Additional info: The whole layout is inherited from RoomSelectionBaseActivity as well. This is my activity_authenticate_room_selection.xml:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          tools:context="de.hhn.mim.vs.roomfactorclient.activities.roomselection.AuthenticateRoomSelectionActivity"&gt;
  
      &lt;include
              layout="@layout/activity_room_selection"
              android:id="@+id/activity_room_selection_include"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"/&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>Many thanks in advance for any help!
  Best,
  Nils</p>