A Listview Is Not Displaying Any Data On Oncreate/onstart After Androidx Migration
I have an app that is only displaying data until I filter something on a SearchView. Now, in the following example, I'm switching between the Home Activity and the More Sites Activ
Solution 1:
Somehow the GetView
method was not called because of a LinerLayout
that contains the ListView
. I re-wrote the Layout and now it works properly.
other_ruins.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><androidx.coordinatorlayout.widget.CoordinatorLayoutandroid:layout_weight="1"android:layout_width="match_parent"android:layout_height="match_parent"><includelayout="@layout/search_container" /><ListViewandroid:id="@+id/lstOtherRuins"app:layout_behavior="@string/appbar_scrolling_view_behavior"android:nestedScrollingEnabled="true"android:layout_margin="8dp"android:layout_height="match_parent"android:layout_width="match_parent"android:choiceMode="singleChoice"android:layout_below="@id/toolbar_container"android:layout_gravity="left|start" /></androidx.coordinatorlayout.widget.CoordinatorLayout><com.google.android.gms.ads.AdViewandroid:id="@+id/adView"android:layout_width="wrap_content"android:layout_height="wrap_content"app:adSize="SMART_BANNER"app:adUnitId="@string/banner_ad_unit_id" /></LinearLayout>
Also, I needed to change the container by adding the AppBarLayout
because it was being overlapped.
search_container.xml:
<?xml version="1.0" encoding="UTF-8" ?><com.google.android.material.appbar.AppBarLayoutxmlns:app="http://schemas.android.com/apk/res-auto"xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/toolbar_container"android:layout_width="match_parent"android:layout_height="wrap_content"><FrameLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><androidx.appcompat.widget.Toolbarandroid:id="@+id/toolbar"app:theme="@style/ToolBarStyle"android:layout_width="match_parent"android:layout_height="?attr/actionBarSize"android:background="@color/colorPrimary" /><com.miguelcatalan.materialsearchview.MaterialSearchViewandroid:id="@+id/search_view"android:layout_width="match_parent"android:layout_height="wrap_content" /></FrameLayout></com.google.android.material.appbar.AppBarLayout>
Post a Comment for "A Listview Is Not Displaying Any Data On Oncreate/onstart After Androidx Migration"