How to stop setEmptyView displaying a TextView while populating a ListView with Android? -


in mainactivty i'm displaying list of items, firebase database using firebaselistadapter this:

firebaselistadapter = new firebaselistadapter<string>(mainactivity.this, string.class, r.layout.list, ref) { @override protected void populateview(final view v, final string listname, int position) {        ((textview )v.findviewbyid(r.id.list_name)).settext(listname);     } }; listview = (listview) findviewbyid(r.id.list_view); listview.setadapter(firebaselistadapter);  textview emptyview = (textview) findviewbyid(r.id.empty_view); listview.setemptyview(emptyview); 

the problem is, when activity starts, emptyview displayed if have data in adapter. happening short time, while listview populated , disappears. how can stop happening? you can see, have set listview.setemptyview(emptyview); after have set firebaselistadapter no luck. how .xml file looks like:

<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/coordinator_layout"     android:layout_width="match_parent"     android:layout_height="match_parent"     tools:context=".mainactivity">      <textview     android:id="@+id/empty_view"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:visibility="gone"/>      <listview     android:id="@+id/list_view"     android:layout_width="match_parent"     android:layout_height="match_parent" /> </android.support.design.widget.coordinatorlayout> 

thanks in advance!

if adapter has method, can set empty view in method,

adapter.registerdatasetobserver(new datasetobserver() {              @override             public void onchanged() {                 super.onchanged();                textview emptyview = (textview) findviewbyid(r.id.empty_view);                listview.setemptyview(emptyview);              }         }); 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -