tags:

views:

83

answers:

1

Hello. I have a little problem. I have class

private static class EfficientAdapter extends BaseAdapter {
        private LayoutInflater mInflater;

        public EfficientAdapter(Context context) {

            mInflater = LayoutInflater.from(context);
        }

        // return size of elements
        public int getCount() {
            return BridgeJSON.listFromJSON.getItem().size();

        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            if (convertView == null) {
                position_move = 0;

                convertView = mInflater.inflate(R.layout.row, null);

                holder = new ViewHolder();

                holder.txt_description = (TextView) convertView
                        .findViewById(R.id.description_event);

                ......

                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }


            if (listFromJSON.getItem().get(position).isViewed() == false) {


                convertView.setBackgroundColor(Color.RED);

                this.notifyDataSetChanged();




            } else {

                // get text for description
                String txt_for_description = listFromJSON.getItem().get(
                        position - position_move).getDescr();

                ..........
            }

            return convertView;
        }

        static class ViewHolder {
            TextView txt_description;
            TextView txt_time;
            TextView txt_title;
            TextView txt_place;
        }
    }

When I do that, method convertView.setBackgroundColor(Color.RED) work great, what I need Image is there: dl.dropbox.com/u/866867/stack/device2.png

but when I want to remove that item, I can't do it. I add there convertView.setVisibility(View.GONE); , but have empty item, beside hide it. I read that parameter View.INVISIBLE won't hide layout, but View.GONE have, but in my code, doesn't(((

And that image: http://dl.dropbox.com/u/866867/stack/device.png

A: 

With adapters, when you want to remove an item, you generally use mAdapter.remove(theObjectToRemove);
and then, you update your ListView :
mListView.notifyDataSetChanged();
However, in your case, you have a BaseAdapter which does not have this method. so can you use an ArrayAdapter instead of BaseAdapter with your set of data?

Or you would have to recreate your baseAdapter after removing what you want to remove from your array.

Sephy
I can't use ArrayAdapter, 'cause I need several TextView in my row.xml. As I know, I can't do it with ArrayAdapter (or can?? I look for, but can't find)
Yaroslav Boichuk
>>Or you would have to recreate your baseAdapter after removing what you want to remove from your array.I think about it, but it's will done in way if can't do anything with that way, but want to try do like that)
Yaroslav Boichuk
Well, you can create an ArrayList<TextView> and then use ArrayAdapter ?
Sephy
Thx, but I won't make it again. I will create new Array with removed items. I think it will be the best way. Thx again for help ;)P.S. When will have free time, try to do with ArrayList<TextView> )
Yaroslav Boichuk