相关疑难解决方法(0)

阻止适配器在滚动时回收视图(编辑不要这样做.)

我有一个自定义基本适配器,它将接收数据的arraylist.从这里开始,它将使用自定义按钮填充网格视图.它完美地完成并填满了gridview.问题是.我想设置一个按钮来改变颜色.当我这样做时,由于视图被回收,它还会更改下一个被回收的视图.防爆.单击位置0处的按钮1.同时更改位置13处的按钮.现在,当我进行一些调试时,我发现它也会更改某些属性.我想知道是否有创建我的视图,因为它不需要回收任何部分的视图.

我已经看到了一些关于使用stableID的事情,但即使我已经将它重写为true.它目前仍然没有改变它.

static class CategoryButtonAdapter extends BaseAdapter
{
    private Context mContext;
    private ArrayList<DishCategory> dishCategories;
    private ArrayList<Dish> dishItems;
    static ArrayList<DishCategoryButton> mDishCategoryButtons;
    //will take in an array list created in the orderlayout that will be the 
    //dish category. This will be the from where we will the count for the adapter
    public CategoryButtonAdapter(Context context, ArrayList<DishCategory> dishCategories)
    {
        this.mContext = context;
        this.dishCategories = dishCategories;

        dishItems  = dishCategories.get(0).getDishes();
    }

    public int getCount() 
    {
        return dishCategories.size();
    }

    //to be implementated later so it can b3e …
Run Code Online (Sandbox Code Playgroud)

android gridview button baseadapter

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×1

baseadapter ×1

button ×1

gridview ×1