如何顺利刷新gridview元素?

时间:2011-08-11 06:44:37

标签: android gridview

I hava an application where i want to change backgroud color dynamically. please suggest me how can i do it. here is my code
Thanks you.
this is my getview()

    public View getView(int position, View convertView, ViewGroup parent) {
            ImageView imageView;
            if (convertView == null) { // if its not recycled, initialize some
                                        // attributes
                imageView = new ImageView(mContext);
                imageView.setLayoutParams(new GridView.`enter code here`LayoutParams(85, 85));
                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                imageView.setPadding(8, 8, 8, 8);
            } else {
                imageView = (ImageView) convertView;
            }

            /**
             * Code for indicate , data content table
             */

            HashMap<Integer, List<OrderlistData>> orederMap1 = ConText
                    .getTotlaMap();
            List<OrderlistData> orderlist1 = new ArrayList<OrderlistData>();
            Set<Integer> keySet1 = orederMap1.keySet();
            if (keySet1.contains(position))
                orderlist1 = orederMap1.get(position);

            if (orderlist1.isEmpty())

                imageView.setBackgroundColor(Color.TRANSPARENT);

            else
                imageView.setBackgroundColor(Color.GREEN);

            imageView.setImageResource(mThumbIds[position]);

            return imageView;
        }

//here is i `set  grid view

    GridView gridview = (GridView) findViewById(R.id.gridview);
                    TableGridViewAdapter adapter=new TableGridViewAdapter(this);

                    adapter.notifyDataSetChanged();
                    gridview.setAdapter(adapter);

0 个答案:

没有答案