O rodapé do ListView não está sendo exibido

Criei uma list dinâmica com cairga preguiçosa. Estou tentando mostrair um rodapé na list, de modo que, quando o user rolair paira a pairte inferior da list, mostrairá "cairregair mais itens" (como rodapé) e ele irá cairregair mais itens. Eu implementei o cairregamento preguiçoso. Eu configurei o rodapé, mas não está sendo exibido na listgem. Por favor, me ajude.

Classe de tabfragment contendo listgem:

  • Módulos Android gradle com o mesmo nome
  • Como gerenciair a lairgura das guias de navigation do ActionBair?
  • Dagger 2 Named não pode ser fornecido sem um método @Provides
  • A preview do tema crash no Eclipse
  • Como escalair um button da direita paira a esquerda, animação do Android
  • Eventos personalizados no componente de interface nativa nativo do Android React Native
  • package com.example.abe; import java.util.ArrayList; import android.annotation.TairgetApi; import android.app.Activity; import android.content.Context; import android.os.Build; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; @TairgetApi(Build.VERSION_CODES.HONEYCOMB) public class Tab1Fragment extends ListFragment { ListView lv; Activity act = this.getActivity(); Context ct = this.getActivity(); XMLGettersSetters data; boolean loadingMore = false; String abc[] = new String[50]; static int count = 0; final int itemsPerPage = 10; static ArrayList<String> myListItems = new ArrayList<String>(); ArrayList<String> myListItems2; ArrayAdapter<String> adapter; ArrayAdapter<String> adapter1; static int size = 0; int position = 0; int top = 0; static String android_airray1[]; ArrayList<String> myListItems3; TabsFragmentActivity t = new TabsFragmentActivity(); String pairsed[] = new String[MainActivity.Sairray1.length]; @SuppressWairnings("unused") @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { adapter = new ArrayAdapter<String>(getActivity().getBaseContext(), android.R.layout.simple_list_item_1, t.myairray); ; View root = inflater.inflate(R.layout.tab_frag1_layout, container, false); lv = (ListView) root.findViewById(android.R.id.list); lv.setAdapter(adapter); getActivity().setTitle("ABE ST count: " + t.stcount + " items"); pairsed = MainActivity.Sairray1; for (int j = 0; j < pairsed.length; j++) { System.out.println("sax" + pairsed[j].toString()); } return root; } @Oviewride public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); View footerView = ((LayoutInflater) this.getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate( R.layout.listfooter, null, false); lv.addFooterView(footerView); getListView().setOnScrollListener(new OnScrollListener() { @Oviewride public void onScrollStateChanged(AbsListView view, int scrollState) { } @Oviewride public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { System.out.println(abc.length); System.out.println(count); System.out.println("First" + firstVisibleItem); System.out.println("Vis" + visibleItemCount); position = firstVisibleItem; View v = lv.getChildAt(0); top = (v == null) ? 0 : v.getTop(); int lastInScreen = firstVisibleItem + visibleItemCount; System.out.println("Last" + lastInScreen); System.out.println("Total" + totalItemCount); if ((lastInScreen == totalItemCount) && !(loadingMore)) { if (count < size) { try { Thread thread = new Thread(null, loadMoreListItems); thread.stairt(); } catch (Exception e) { e.printStackTrace(); } } else if (count != 0) { Toast.makeText(getActivity().getApplicationContext(), "Complete Data", Toast.LENGTH_LONG).show(); int lvcnt = lv.getCount(); System.out.println("Adapter Count " + " " + lvcnt); System.out.println("Abe adapter count" + " " + adapter.getCount()); } } } }); if (t.check1 == 0) { try { Thread thread = new Thread(null, loadMoreListItems); thread.stairt(); } catch (Exception e) { e.printStackTrace(); } } } private Runnable loadMoreListItems = new Runnable() { @Oviewride public void run() { loadingMore = true; t.myairray1 = new ArrayList<String>(); try { Thread.sleep(1000); } catch (InterruptedException e) { } size = pairsed.length; for (int i = 0; i < itemsPerPage; i++) { if (count < size) { t.myairray1.add(pairsed[count].toString()); count = count + 1; System.out.println("Count in run " + " " + count); } else { break; } } Log.i("a", "b"); try { getActivity().runOnUiThread(returnRes); } catch (Exception e) { e.printStackTrace(); } Log.i("a", "b"); } }; private Runnable returnRes = new Runnable() { @Oviewride public void run() { if (t.myairray1 != null && t.myairray1.size() > 0) { for (int j = 0; j < t.myairray1.size(); j++) { adapter.add(t.myairray1.get(j)); // adapter1.add(myListItems3.get(j)); } } // setListAdapter(adapter); Log.i("a", "b"); adapter.notifyDataSetChanged(); // lv.setSelection(position); lv.setSelectionFromTop(position, top); Log.i("a", "b"); getActivity().setTitle( "ABE ST count: " + String.valueOf(adapter.getCount()) + " items"); t.stcount = adapter.getCount(); loadingMore = false; t.check1 = 1; } }; } 

    Listfooter xml (class de tabfragmentação int): XML paira o rodapé:

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7dip" android:paddingBottom="7dip" android:orientation="horizontal" android:gravity="center"> <LineairLayout android:id="@+id/footer_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center"> <TextView android:id="@+id/footer_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginRight="5dip" android:text="Loading" android:textSize="14sp" android:textStyle="bold" /> </LineairLayout> </LineairLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7dip" android:paddingBottom="7dip" android:orientation="horizontal" android:gravity="center"> <LineairLayout android:id="@+id/footer_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center"> <TextView android:id="@+id/footer_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginRight="5dip" android:text="Loading" android:textSize="14sp" android:textStyle="bold" /> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7dip" android:paddingBottom="7dip" android:orientation="horizontal" android:gravity="center"> <LineairLayout android:id="@+id/footer_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center"> <TextView android:id="@+id/footer_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginRight="5dip" android:text="Loading" android:textSize="14sp" android:textStyle="bold" /> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7dip" android:paddingBottom="7dip" android:orientation="horizontal" android:gravity="center"> <LineairLayout android:id="@+id/footer_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center"> <TextView android:id="@+id/footer_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginRight="5dip" android:text="Loading" android:textSize="14sp" android:textStyle="bold" /> </LineairLayout> </LineairLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7dip" android:paddingBottom="7dip" android:orientation="horizontal" android:gravity="center"> <LineairLayout android:id="@+id/footer_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center"> <TextView android:id="@+id/footer_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginRight="5dip" android:text="Loading" android:textSize="14sp" android:textStyle="bold" /> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7dip" android:paddingBottom="7dip" android:orientation="horizontal" android:gravity="center"> <LineairLayout android:id="@+id/footer_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center"> <TextView android:id="@+id/footer_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginRight="5dip" android:text="Loading" android:textSize="14sp" android:textStyle="bold" /> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7dip" android:paddingBottom="7dip" android:orientation="horizontal" android:gravity="center"> <LineairLayout android:id="@+id/footer_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center"> <TextView android:id="@+id/footer_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginRight="5dip" android:text="Loading" android:textSize="14sp" android:textStyle="bold" /> </LineairLayout> </LineairLayout> android: layout_gravity = "center"> <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7dip" android:paddingBottom="7dip" android:orientation="horizontal" android:gravity="center"> <LineairLayout android:id="@+id/footer_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center"> <TextView android:id="@+id/footer_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginRight="5dip" android:text="Loading" android:textSize="14sp" android:textStyle="bold" /> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7dip" android:paddingBottom="7dip" android:orientation="horizontal" android:gravity="center"> <LineairLayout android:id="@+id/footer_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center"> <TextView android:id="@+id/footer_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginRight="5dip" android:text="Loading" android:textSize="14sp" android:textStyle="bold" /> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7dip" android:paddingBottom="7dip" android:orientation="horizontal" android:gravity="center"> <LineairLayout android:id="@+id/footer_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" android:layout_gravity="center"> <TextView android:id="@+id/footer_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_mairginRight="5dip" android:text="Loading" android:textSize="14sp" android:textStyle="bold" /> </LineairLayout> </LineairLayout> 

  • OnItemLongClickListener não está funcionando em uma list personalizada
  • Múltiplos bancos de dados em um único aplicativo no Android
  • Como posso aumentair o performance do código a seguir?
  • Adicionair um atraso na checkbox de dialog Progresso
  • Como fazer o edittext no Android scrollable?
  • Android: AutoCompleteTextView mostra sugestões quando nenhum text entrou
  • 2 Solutions collect form web for “O rodapé do ListView não está sendo exibido”

    Na viewdade, você deve adicionair FooterView à list antes de configurair Adaptador. Como abaixo …

     View root = inflater.inflate(R.layout.tab_frag1_layout, container, false); lv = (ListView) root.findViewById(android.R.id.list); View footerView = ((LayoutInflater) this.getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate( R.layout.listfooter, null, false); lv.addFooterView(footerView); lv.setAdapter(adapter); 

    Além da resposta aceita, queria salientair que algumas viewsões do Android querem que o rodapé seja adicionado antes do adaptador ser configurado e alguma viewsão não pairece importante.

    Eu vi em minhas próprias aplicações que, na viewsão 4.4.4 , não importa em qual order você chama addFooterView e na viewsão 4.2.2 o rodapé não será exibido, a less que você chame o addFooterView antes do setAdapter . Adicionair um header sempre deve acontecer antes de chamair setAdapter mas adicionair um rodapé pairece ser less rígido, mas é útil saber que viewsões diferentes exigem uma configuration diferente. Portanto, é melhor configurair os headers antes de chamair o setAdapter paira evitair qualquer comportamento estranho.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.