给RecycleView的adapter的加载list更新了,notifyDataSetChanged()无效,未更新

请问大神,为什么,我在给RecycleView的adapter的加载list更新了,notifyDataSetChanged()无效,未更新

package sunland.com.itaxi.ui.illegal;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import sunland.com.itaxi.R;
import sunland.com.itaxi.bean.IllegalBean;
import sunland.com.itaxi.bean.IllegalTypeBean;
import sunland.com.itaxi.bean.PlateListBean;
import sunland.com.itaxi.ui.punish.penalties.PenaltiesActivity;

/**
 * Created by zjl on 2016/9/21.
 */

public class IllegalAdapter extends RecyclerView.Adapter<IllegalAdapter.MyViewHolder> {

    private List<IllegalBean> list;
    private Context context;
    private int type;
    private int platform;
    private ArrayList<IllegalTypeBean> typelist = new ArrayList<>();
    private ArrayList<PlateListBean> platformlist = new ArrayList<>();

    @Inject
    public IllegalAdapter(Context context) {
        this.context = context;
    }

    public void bind(List<IllegalBean> list) {
        Log.d("zjlsize+",""+list.size());
        this.list = list;//list赋值是改变了
//notifyDataSetChanged();里面写也是无效的
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_illegal_recycleview_item, parent, false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }


    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.pos = position;
        Log.d("zjl**istrue", "*" + list.get(position).isIsTrue());
        if (!list.get(position).isIsTrue()) {
            holder.hide_rl.setVisibility(View.VISIBLE);
            holder.hide_rl.getBackground().setAlpha(204);
            holder.ifclick = 0;
        } else {
            holder.hide_rl.setVisibility(View.GONE);
            holder.ifclick = 1;
        }
        if (list.get(position).getGender() == 0) {
            holder.offender_portrait_rv.setImageDrawable(context.getResources().getDrawable(R.drawable.woman));
        } else {
            holder.offender_portrait_rv.setImageDrawable(context.getResources().getDrawable(R.drawable.man));
        }
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public interface OnItemClickLitener {
        void onItemClick(IllegalBean illegalBean, int position);
    }

    private OnItemClickLitener mOnItemClickLitener;

    public void setOnItemClickLitener(OnItemClickLitener mOnItemClickLitener) {
        this.mOnItemClickLitener = mOnItemClickLitener;
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.activity_illegal_recycleview_item_show_rl)
        RelativeLayout show_rl;
        @BindView(R.id.activity_illegal_recycleview_item_hide_rl)
        RelativeLayout hide_rl;
        @BindView(R.id.offender_portrait_rv)
        ImageView offender_portrait_rv;
        @BindView(R.id.offender_name_tv)
        TextView offender_name_tv;
        @BindView(R.id.offender_vehicleNum_tv)
        TextView offender_vehicleNum_tv;
        @BindView(R.id.offender_illegal_date_tv)
        TextView offender_illegal_date_tv;
        @BindView(R.id.offender_illegal_type_tv)
        TextView offender_illegal_type_tv;
        @BindView(R.id.offender_illegal_place_tv)
        TextView offender_illegal_place_tv;
        @BindView(R.id.offender_carinfo_platform_tv)
        TextView offender_carinfo_platform_tv;
        @BindView(R.id.offender_carinfo_area_tv)
        TextView offender_carinfo_area_tv;
        @BindView(R.id.offender_describe_tv)
        TextView offender_describe_tv;
        @BindView(R.id.offender_carsource_iv)
        ImageView offender_carsource_iv;

        IllegalBean illegalBean;
        int pos;
        int ifclick = 1;//是否可点击

        @OnClick(R.id.activity_illegal_recycleview_item_show_rl)
        void listItemClick() {
            if (mOnItemClickLitener != null) {
                if (ifclick == 0) {
                    //对“正在处理中”的处理

                } else {
                    mOnItemClickLitener.onItemClick(list.get(pos), pos);
                }
            }

        }

        public MyViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

    }
}

代码如上,我使用了代码
 
         adapter.bind(illegallist);
         adapter.notifyDataSetChanged();

获取bind()方法里的Log,发现list是改变了的,但是notifyDataSetChanged()无效。
求大神帮助!!!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值