[Android Studio] zinkenmartin:
I have some problems with the list items of a ListView. I've implemented a Navigation Drawer Activity and want to display a simple ListView with some list items. I haven't changed the implementation of the navigation bar yet, just tried to display an activity I've already implemented. So in the automatically generated app_bar_start.xml I just replaced in the <include layout="@layout/activity_main_list" /> section the example activity by my own activity. So far so good, but I figured out that the list items, I want to add by an ArrayAdapter, doesn't appear in the app.

On the other hand, when I implement an string-array in strings.xml and include this items via android:entries in the xml file of my activity, it works fine.

Also when I display my activity directly, so without the Navigation Drawer Activity, everything works fine too.

So does anybody have an idea why it just don't work included in the Navigation Drawer Acitivity?

MainList.java (this is my own written activity):

public class MainList extends AppCompatActivity {
private ListView mListView;

[MENTION=439709]override[/MENTION]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_list);
mListView = (ListView) findViewById(R.id.mainlist);
List<String> list = new ArrayList<String>();
list.add("Dies ist ein Test");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
mListView.setAdapter(adapter);
}
}

activity_main_list.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="..."
xmlns:app="..."
xmlns:tools="..."
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_start"
tools:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp">
<ListView
android:id="@+id/mainlist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_green_dark"
android:clickable="true"
android:focusable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
</android.support.constraint.ConstraintLayout>

StartActivity.java:

public class StartActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {

[MENTION=439709]override[/MENTION]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
}

activity_start.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="..."
xmlns:app="..."
xmlns:tools="..."
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_start"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_start"
app:menu="@menu/activity_start_drawer" />
</android.support.v4.widget.DrawerLayout>

app_bar_start.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="..."
xmlns:app="..."
xmlns:tools="..."
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="martinfactory.archibook.StartActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/activity_main_list" />
</android.support.design.widget.CoordinatorLayout>