2
我在导航抽屉适配器中遇到了一些问题。 它应该显示如下的项目:Favorito,Categorias和分类下的小型子类别。导航抽屉中的动态布局会遗弃视图
我对导航抽屉适配器进行了编程,默认情况下使用big_layout.xml文件,但是如果它的位置大于某个值,那么它使用small_layout.xml文件。
它对前几项工作正常,但问题是当我向下滚动查看其余项目时,他们使用big_layout.xml,然后当我向后滚动时,原始大项目会更改它们查看和使用小布局!
下面是代码,这是坏的结果的屏幕截图:http://i.stack.imgur.com/QWwts.jpg
@Override
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
LayoutInflater laoutInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (getItemId(position)>3)
view = laoutInflater.inflate(R.layout.drawer_list_item_small, null);
if (getItemId(position)<=3)
view = laoutInflater.inflate(R.layout.drawer_list_item, null);
}
ImageView icon = (ImageView) view.findViewById(R.id.icon);
icon.setImageResource(drawerItems.get(position).getIcon());
TextView title = (TextView) view.findViewById(R.id.title);
title.setText(drawerItems.get(position).getTitle());
return view;}
这有什么错我在干什么? ,是否有什么缺失,可能是视图稳定负责?
我该如何解决这个问题?
非常感谢!这确实解决了我的问题。竖起大拇指 –