Problema al eliminar el pie de página de ListView con removeFooterView ()

Estoy intentando quitar el pie de página que he fijado usando la misma referencia que utilizé para fijarla para arriba. Sin embargo, no pasa nada.

protected void onPostExecute(ArrayList<Recipe> result) { int CHEF_ID = ChefsRecipeList.this.getIntent().getIntExtra("CHEF_ID", 0); ListView recipeListView = (ListView)findViewById(android.R.id.list); View footer = getLayoutInflater().inflate(R.layout.chef_recipe_list_footer, null); if(!addToExisting){ RecipeManager.getInstance().setRecipeList(result); View header = getLayoutInflater().inflate(R.layout.chef_recipe_list_header, null); ImageView loadButton = (ImageView)footer.findViewById(R.id.loadmore); loadButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { int CHEF_ID = ChefsRecipeList.this.getIntent().getIntExtra("CHEF_ID", 0); try { Log.d("NXTLAOD", "http://api.foodnetworkasia.com/api/mobile/get_recipes?chefId="+ChefManager.getInstance().getChef(CHEF_ID).getId()+ "&format=xml&startIndex="+(RecipeManager.getInstance().getRecipeList().size()+1)+"&endIndex="+(RecipeManager.getInstance().getRecipeList().size()+24)); new XMLRecipesParser(true).execute(new URL[] { new URL("http://api.foodnetworkasia.com/api/mobile/get_recipes?chefId="+ChefManager.getInstance().getChef(CHEF_ID).getId()+ "&format=xml&startIndex="+RecipeManager.getInstance().getRecipeList().size()+"&endIndex="+(RecipeManager.getInstance().getRecipeList().size()+24)) } ); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); ImageView chefPhoto = (ImageView)header.findViewById(R.id.chef_photo); chefPhoto.setImageBitmap(ImageURLLoader.LoadImageFromURL(ChefManager.getInstance().getChef(CHEF_ID).getLargeURL())); TextView chefBio = (TextView)header.findViewById(R.id.chef_bio); chefBio.setText(ChefManager.getInstance().getChef(CHEF_ID).getDescription()); recipeListView.addHeaderView(header); recipeListView.addFooterView(footer); recipeListView.setAdapter(new RecipeAdapter(ChefsRecipeList.this)); }else{ RecipeManager.getInstance().mergeLists(result); RecipeAdapter wrapperAdapter=(RecipeAdapter) ((HeaderViewListAdapter)recipeListView.getAdapter()).getWrappedAdapter(); wrapperAdapter.notifyDataSetChanged(); } if(totalRecipes == RecipeManager.getInstance().getRecipeList().size()){ recipeListView.removeFooterView(footer); Log.d("FOODREM", "Footer Removed"); } Log.d("ITCOUNT", totalRecipes+"-"+RecipeManager.getInstance().getRecipeList().size()); updateItemscount(); } } 

Es posible que tenga que llamar a listView1.setAdapter(adapter) para actualizar la vista de lista. Si eso no funciona, otra solución es hacer que la altura de la vista de pie de página a 0px. Esta es una solución mejor si está planeando usar la vista de pie de página más adelante.

También puede configurar la visibilidad de pie de página para GONE. Para hacer eso, necesitas envolver el contenido de tu pie de página usando un linearlayout, y luego establecer la visibilidad linearlayout a GONE.

En el ejemplo abajo establecí la visibilidad de LogoLinearLayout en GONE.

  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:id="@+id/LogoLinearLayout" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/Logo" android:src="@drawable/Logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/spacing3" android:layout_marginBottom="@dimen/spacing3" android:layout_gravity="center" /> </LinearLayout> </LinearLayout> 

He visto este tipo de solución (la configuración de la altura de la vista de pie de página a 0, o la fijación de márgenes negativos ..) en muchos puestos relacionados con ocultar el pie de página, y funciona, pero con 2 cuestiones: – la lista no respetará la transcriptMode = "normal", en el sentido de que, si el último elemento es visible y se agrega un nuevo elemento a la lista, la lista no se desplazará al elemento recién agregado; – Cuando se muestra el teclado y se cambia el tamaño de la lista, de nuevo la lista no mostrará el último elemento.

  • Agregar un encabezado / pie de página en un listview en xml
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.