问题删除使用removeFooterView ListView的页脚() [英] Problem removing ListView footer using removeFooterView()
本文介绍了问题删除使用removeFooterView ListView的页脚()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图删除页脚我已经用我用它设置相同的基准设置。然而,没有任何反应。
保护无效onPostExecute(ArrayList的<&配方GT;的结果){ INT CHEF_ID = ChefsRecipeList.this.getIntent()getIntExtra(CHEF_ID,0); ListView控件recipeListView =(ListView控件)findViewById(android.R.id.list); 查看页脚= getLayoutInflater()膨胀(R.layout.chef_recipe_list_footer,NULL);
如果(!addToExisting){ RecipeManager.getInstance()setRecipeList(结果)。 查看标题= getLayoutInflater()膨胀(R.layout.chef_recipe_list_header,NULL); ImageView的loadButton =(ImageView的)footer.findViewById(R.id.loadmore); loadButton.setOnClickListener(新OnClickListener(){ @覆盖
公共无效的onClick(视图v){ INT CHEF_ID = ChefsRecipeList.this.getIntent()getIntExtra(CHEF_ID,0); 尝试{ 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));
新XMLRecipesParser(真).execute(新URL [] {新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)) }); }赶上(MalformedURLException的E){
// TODO自动生成catch块
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(头);
recipeListView.addFooterView(页脚); recipeListView.setAdapter(新RecipeAdapter(ChefsRecipeList.this)); }其他{ 。RecipeManager.getInstance()mergeLists(结果); RecipeAdapter wrapperAdapter =(RecipeAdapter)((HeaderViewListAdapter)recipeListView.getAdapter())getWrappedAdapter();
wrapperAdapter.notifyDataSetChanged(); } 如果(totalRecipes == RecipeManager.getInstance()。getRecipeList()。大小()){ recipeListView.removeFooterView(页脚);
Log.d(FOODREM,页脚删除); } Log.d(ITCOUNT,totalRecipes + - + RecipeManager.getInstance()getRecipeList()的大小());
updateItemscount(); }}
解决方案
您可能需要调用 listView1.setAdapter(适配器)
来刷新列表视图。如果不工作,另一种解决方案是使页脚视图的高度为0px。这是一个更好的解决方案,如果你打算以后再次上使用的页脚视图。
I am trying to remove footer I've set using the same reference I used to set it up. However, nothing happens.
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();
}
}
解决方案
You might have to call listView1.setAdapter(adapter)
to refresh the listview. If that doesn't work, another solution is to make the height of the footer view to 0px. This is a better solution if you are planning to use the footer view later on again.
这篇关于问题删除使用removeFooterView ListView的页脚()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文