Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Header in ListView disappears?
    primarykey
    data
    text
    <p>I've been experiencing a very weird bug lately... and simply don't know what to do...</p> <p>I have a "Tabbed-Fragment-Activity", which means I needed a tabhost on the bottom so I used google's API example, which manages fragments via the TabHost (&amp; Manager) Almost each tab is actually a ListFragment and to each I add an header at "OnActivityCreated".</p> <p>Now the weird thing is : When i move to a tab (ListFragment) the first time, I can see the header, but once I move from the tab and afterwards move back to it, the header is GONE !!!</p> <p>This is the code I'm using :</p> <pre><code>private boolean initialized = false; private TextView m_Header = null; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { String listTitle = "HELLO HUMAN" if(m_Header == null &amp;&amp; !Helpers.isNullOrBlank(listTitle)) { m_Header = (TextView)inflater.inflate(R.layout.newslist_header, null, false); m_Header.setText(listTitle); } return super.onCreateView(inflater, container, savedInstanceState); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if(!initialized) { ListView list = getListView(); if(m_Header != null) { list.addHeaderView(m_Header); } this.m_adapter = new SomeAdapter(); setListAdapter(this.m_adapter); registerForContextMenu(list); this.initialized = true; } } </code></pre> <p>I'm using this "initialized" boolean as to not call "setListAdapter"/"addHeader" each time I load the fragment (otherwise you get a nasty exception saying you can't add header after setting the adapter...)</p> <p>Errr... i'm clueless @ this point...</p> <p>please help :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload