可扩展列表视图的组视图的前6或7项不刷新

时间:2014-02-14 02:23:09

标签: android expandablelistview android-ui

我想实现一个功能,当我点击可展开列表视图的groupview项时,该项目将显示一个新的imageview。如果我点击列表视图中的No.9或No.10,那么如果我点击列表视图中的前6或7(移动电话上的depand)项目,那么就没事了。所以我不知道如何修复这个问题。

可扩展列表视图的适配器如下:

class RouteLineAdapter extends BaseExpandableListAdapter {
        boolean isMt = false;
        List<HashMap<String, String>> busRouteListInner = new ArrayList<HashMap<String, String>>();

        RouteLineAdapter(boolean isMt) {
            this.isMt = isMt;
            if (isMt) busRouteListInner = busRouteListMt;
            else busRouteListInner = busRouteListMo;
        }

        @Override
        public Object getGroup(int groupPosition) {
            if (groupPosition < busRouteListInner.size())
                return busRouteListInner.get(groupPosition).get("station_name");
            else return "";
        }

        @Override
        public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
            View view = convertView;
            final Animation refreshAnimation = AnimationUtils.loadAnimation(RealTime.this, R.anim.refresh_progress);
            if (convertView == null) {
                LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = inflater.inflate(R.layout.member_listview, null);
            }

            TextView busNo = (TextView) view.findViewById(R.id.busNumMember);
            TextView stationName = (TextView) view
                    .findViewById(R.id.stationNameMember);
            final ImageView refreshImageView = (ImageView) view.findViewById(R.id.refresh_businfo);
            final ImageView collectImageView = (ImageView) view.findViewById(R.id.collect_businfo);

            String tempSearchStationId = searchStationId;
            if (!isMt && (groupCountMt > 0) && ((BasicUtils.convertStringToInt(searchStationId) - 1) > groupCountMt)) {
                tempSearchStationId = BasicUtils.convertStringToInt(searchStationId) - groupCountMt + "";
            }

            if (refreshState == 1 && (BasicUtils.convertStringToInt(tempSearchStationId) - 1 == groupPosition)) {
                refreshImageView.startAnimation(refreshAnimation);


            } else if (refreshState == 0) {
                refreshImageView.clearAnimation();
            }

            if (refreshState == 2 && (BasicUtils.convertStringToInt(tempSearchStationId) - 1 == groupPosition)) {
               //it execute here,but not show imageview at the top item
               Logs.d("is execuated");
                refreshImageView.setVisibility(View.VISIBLE);                refreshImageView.startAnimation(refreshAnimation);
                refreshState = 3;
            }

            return view;
        }

        @Override
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {

            try {
                if (convertView == null) {
                    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    convertView = inflater.inflate(R.layout.member_childitem, null);
                }
                globalView = convertView;
                if (groupPosition != searchLocation) {
                    Logs.d(busDataList.get(0).get("station_count_remain") + "   remain");
                    getBusInfoDetail(convertView);
                    searchLocation = groupPosition;
                }
            } catch (Exception e) {
                e.printStackTrace();
                Logs.e(e.getMessage(), "");
            }
            return convertView; 
        }

    }



在处理程序中,程序执行

routeLineAdapterMt.notifyDataSetChanged();
routeLineAdapterMt.notifyDataSetInvalidated(); 

让列表视图刷新

0 个答案:

没有答案