Android Wieso kann ich keine ListView mehr zum Layout hinzufügen?

Windows10

Bekanntes Mitglied
Ich habe von meiner Android App das Layout fertig, bekomme aber keine ListView mehr angezeigt in meiner MainActivity.

Mit Menü:
mit Menü.png


Ohne Menü:
ohne Menü.png

Auf die freie Fläche will ich noch eine ListView anzeigen und einen FloatingActionButton, aber irgendwie kommt der immer in den türkisen Berich oben hin und ist nicht verschiebbar (springt immer wieder nach oben) und die ListView wird überhaupt nicht angezeigt.

Weiß jemand was es da haben könnte?

Wenn ihr den Code oder die .xml-Dateien braucht bitte melden und sagen welche benötigt werden, da ich sonst alle gleich hinzufügen muss, was ziemlich viel werden könnte.

Danke für die Hilfe.
 
activity_main.xml:
XML:
<?xml version="1.0" encoding="utf-8"?>
    <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbatHome"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAlignment="center"
                app:contentInsetEnd="0dp"
                app:contentInsetStart="0dp"
                android:background="@color/colorAccent">
                <include layout="@layout/toolbar"/>
            </androidx.appcompat.widget.Toolbar>

    </com.google.android.material.appbar.AppBarLayout>

    <FrameLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

    <com.google.android.material.navigation.NavigationView
    android:id="@+id/mDrawerLayout"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="false"
    android:layout_marginStart="30dp"
    app:headerLayout="@layout/header"
    app:menu="@menu/drawer_menu"
    app:itemTextColor="@color/colorPrimaryDark"/>

    </androidx.drawerlayout.widget.DrawerLayout>

header.xml:
XML:
<?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="150dp"
    android:orientation="horizontal"
    android:padding="20dp"
    android:background="@color/colorPrimaryDark">
    <TextView
    android:id="@+id/userNameEditText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="18sp"
    android:layout_marginTop="24dp"
    android:text="@string/app_name"
    android:textColor="@android:color/white"
    android:textSize="16sp"
    android:textStyle="bold"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

toolbar.xml:
XML:
<?xml version="1.0" encoding="utf-8"?>

    <androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:layout_gravity="top" >

    <TextView
    android:id="@+id/toolbarTitle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="20sp"
    android:gravity="center"
    android:clickable="true"
    android:focusable="true"
    android:layout_marginEnd="60dp"/>
</androidx.appcompat.widget.Toolbar>

MainActivity:
Java:
package ue.list.dotolist;

import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.drawerlayout.widget.DrawerLayout;

import android.os.Bundle;
import android.view.MenuItem;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.google.android.material.navigation.NavigationView;

import butterknife.BindView;

public class MainActivity extends AppCompatActivity {
    private DrawerLayout mDrawerLayout;
    private ActionBarDrawerToggle mToggle;
    @BindView(R.id.mDrawerLayout)
    NavigationView navigationView;
    @BindView(R.id.container)
    FrameLayout container;
    @BindView(R.id.toolbar)
    Toolbar myToolbar;
    @BindView(R.id.toolbarTitle)
    TextView toolbarTitle;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setupUi();
    }

    private void setupUi() {
        mDrawerLayout = findViewById(R.id.drawer);
        mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, myToolbar, R.string.open, R.string.close);
        mDrawerLayout.addDrawerListener(mToggle);
        mDrawerLayout.setClickable(true);
        setSupportActionBar(myToolbar);
        mToggle.setDrawerIndicatorEnabled(true);
        mToggle.syncState();
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (mToggle.onOptionsItemSelected(item)) {
            return true;
        } else {
            return super.onOptionsItemSelected(item);
        }
    }
}

build.gradle:

Code:
apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "ue.list.dotolist"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation 'androidx.drawerlayout:drawerlayout:1.1.0'
    implementation 'com.google.android.material:material:1.2.0'
    implementation 'com.jakewharton:butterknife:10.2.3'
    implementation 'androidx.annotation:annotation:1.1.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}
 

Neue Themen


Zurück
Oben